/* Palette inspirée de Flat UI Colors 2 (flatuicolors.com) */
:root {
  --bg: #ecf0f1;
  --surface: #ffffff;
  --ink: #2c3e50;
  --ink-soft: #7f8c8d;
  --topbar: #ffffff;
  --topbar-ink: #2c3e50;
  --topbar-ink-dim: rgba(44,62,80,0.78);
  --topbar-border: rgba(44,62,80,0.18);
  --btn-bg: var(--trm-zinc-200);
  --primary: #2980b9;
  --danger: #c0392b;
  --line: #dfe4ea;
  --ref-bg: #f7f9fb;
  --redline: #e74c3c;
  --spent-overlay: rgba(44,62,80,0.10);

  /* Charte Toi-Reviens-Moi, portée sur les boutons et champs du bandeau
     du haut (couleurs Tailwind zinc/red officielles, pas d'approximation). */
  --trm-zinc-100: #f4f4f5;
  --trm-zinc-200: #e4e4e7;
  --trm-zinc-300: #d4d4d8;
  --trm-zinc-400: #a1a1aa;
  --trm-zinc-500: #71717a;
  --trm-zinc-800: #27272a;
  --trm-zinc-900: #18181b;
  --trm-red-600: #dc2626;
  --trm-red-700: #b91c1c;

  --team1: #a8d8ea;
  --team2: #f4a9a8;
  --team3: #b3e2a7;
  --team4: #ffd6a5;
  --team-ink: #2c3e50;

  --tier6: #e3f2fb;
  --tier5: #eaf1f6;
  --tier4: #f2f4f6;
  --tier3: #faf0ea;
  --tier2: #fbe4de;
}

/* JS pose toujours data-theme avant le premier rendu (voir le script
   bloquant dans <head>), donc un seul sélecteur explicite suffit ici. */
:root[data-theme="dark"] { --bg: #16191c; --surface: #1e2226; --ink: #ecf0f1; --ink-soft: #98a2ab; --line: #33383e; --ref-bg: #23272c; --tier6: #1c2a33; --tier5: #202428; --tier4: #22262a; --tier3: #2a2422; --tier2: #2e2220; --spent-overlay: rgba(236,240,241,0.10); --topbar: #18181b; --topbar-ink: #f4f4f5; --topbar-ink-dim: rgba(244,244,245,0.88); --topbar-border: rgba(244,244,245,0.35); --btn-bg: var(--trm-zinc-100); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px;
  background: var(--topbar);
  color: var(--topbar-ink);
  border-bottom: 1px solid var(--line);
}

.topbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand-logo {
  height: 28px;
  width: auto;
  display: none; /* activé automatiquement dès qu'un src est renseigné */
}
.brand-logo[src] { display: block; }

.brand-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--topbar-ink);
  white-space: nowrap;
}

/* Épreuve/Étape sur une ligne, Lieu/Date sur la suivante */
.race-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Champ "standard" de Toi-Reviens-Moi : bordure zinc-300, focus zinc-500,
   sans ring — fond et texte suivent le thème pour ne pas jurer avec le
   bandeau du haut (blanc trop criard en thème sombre sinon). */
.race-field {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink);
}
.race-field::placeholder { color: var(--trm-zinc-400); }
.race-field:focus {
  outline: none;
  border-color: var(--trm-zinc-500);
}

.actions-top, .actions-game { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* Bouton "card" de Toi-Reviens-Moi — fond clair sur bandeau clair, fond
   zinc-100 sur bandeau sombre (var(--btn-bg) bascule avec le thème) ; pas de
   transition ni de ring au focus dans leur charte, on reste fidèle. */
.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  background: var(--btn-bg);
  color: var(--trm-zinc-900);
  cursor: pointer;
}
.btn:hover, .btn:active { background: var(--trm-zinc-300); }
.btn-danger { background: var(--trm-red-600); color: white; }
.btn-danger:hover, .btn-danger:active { background: var(--trm-red-700); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:disabled:hover { background: var(--btn-bg); }

/* Bouton rond icône seule du bandeau du haut — partagé par le burger
   Administration et le toggle clair/sombre (visuel repris du composant
   ThemeToggle de Toi-Reviens-Moi). */
.icon-btn {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--topbar-border);
  background: transparent;
  color: var(--topbar-ink-dim);
  cursor: pointer;
}
.icon-btn:active {
  border-color: var(--topbar-ink-dim);
  color: var(--topbar-ink);
}
.icon-btn svg {
  width: 16px;
  height: 16px;
}
/* Deux icônes SVG toujours dans le DOM pour le toggle, on bascule leur
   visibilité au lieu de reconstruire le SVG en JS. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.turn-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.turn-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

.turn-boxes {
  display: flex;
  gap: 4px;
}

.turn-box {
  width: 27px;
  height: 27px;
  min-width: 27px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ref-bg);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  cursor: default;
}

.turn-box.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  cursor: pointer;
}

/* Tour déjà joué : verrouillé, pas de retour en arrière possible */
.turn-box.passed {
  background: var(--spent-overlay);
  border-color: var(--line);
  color: var(--redline);
  font-weight: 700;
}

.sheet-wrap {
  overflow: auto;
  padding: 10px 6px;
  -webkit-overflow-scrolling: touch;
}

/* .sheet-table (pas seulement #sheet) : la grille est aussi rejouée en
   lecture seule dans "Fin d'étape" (voir renderSheetInto), d'où la classe
   partagée plutôt qu'un sélecteur d'ID à usage unique. */
.sheet-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(44,62,80,0.15);
}

/* Largeurs en % pour que la grille remplisse tout le viewport, quelle
   que soit la taille de l'écran (19 colonnes : 2 réf + 1 respiration + 16 coureurs). */
.col-ref { width: 4.5%; }
.col-data { width: 5.5625%; }
.col-spacer { width: 2%; }

/* Respiration entre la colonne PE/PI et les équipes.
   La ligne rouge continue de traverser cet espace (règle plus bas,
   "tr[data-redline] td", qui cible aussi .spacer). */
.sheet-table td.spacer, .sheet-table th.spacer {
  background: var(--bg);
  border-top: none;
  border-bottom: none;
  border-left: none;
  border-right: none;
}

.sheet-table th, .sheet-table td {
  border: 1px solid var(--line);
  text-align: center;
  padding: 0;
}

/* Copie en lecture seule affichée dans "Fin d'étape" : pas de curseur
   pointeur (aucun clic n'y fait rien), et les noms n'ont plus le liseré au
   focus d'un champ éditable puisque contentEditable est désactivé. */
.sheet-table--preview td.cell { cursor: default; }

/* Séparation marquée entre chaque équipe */
.team-start {
  border-left: 3px solid var(--ink) !important;
}

/* Cases PE/PI encadrées comme sur la feuille papier : bordure plus
   marquée que le simple quadrillage des cases coureurs. Le préfixe
   .sheet-table est nécessaire pour dépasser la spécificité de la
   règle ".sheet-table th, .sheet-table td" définie plus haut. */
.sheet-table .ref-col-pe, .sheet-table .ref-col-pi {
  border: 2px solid var(--ink);
  background: var(--ref-bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  height: 30px;
  vertical-align: middle;
}

.team-head {
  color: var(--team-ink);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}
.team-head[data-team="0"] { background: var(--team1); }
.team-head[data-team="1"] { background: var(--team2); border-left: 3px solid var(--ink); }
.team-head[data-team="2"] { background: var(--team3); border-left: 3px solid var(--ink); }
.team-head[data-team="3"] { background: var(--team4); border-left: 3px solid var(--ink); }

.cyclist-head {
  font-size: 11px;
  padding: 5px 2px;
  background: var(--ref-bg);
  line-height: 1.2;
}

.cyclist-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  outline: none;
  cursor: text;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}
.cyclist-status {
  display: block;
  outline: none;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 9px;
  font-weight: 700;
  color: var(--danger);
  height: 12px;
}

.pi-tier-6 { background: var(--tier6); }
.pi-tier-5 { background: var(--tier5); }
.pi-tier-4 { background: var(--tier4); }
.pi-tier-3 { background: var(--tier3); }
.pi-tier-2 { background: var(--tier2); }

/* Ligne rouge : seuil de report de fatigue entre étapes. */
tr[data-redline="true"] td {
  border-top: 3px solid var(--redline) !important;
}

td.cell {
  height: 30px;
  cursor: pointer;
  position: relative;
}

td.cell.spent {
  background-color: var(--spent-overlay);
}

td.cell.spent::after {
  content: "✕";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--redline);
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
}

td.cell.current-row {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.hint {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  margin: 4px 14px 16px;
}

/* ---- Historique des étapes ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-backdrop.hidden { display: none; }

/* Bannière d'alerte quand saveState() échoue (quota localStorage dépassé,
   navigation privée stricte, stockage bloqué par une extension...) : sans
   ça l'échec ne finissait qu'en console.warn, invisible pour l'utilisateur,
   qui croyait sa progression enregistrée alors qu'elle ne l'était pas.
   z-index au-dessus des modales pour rester visible même si l'échec
   survient pendant la saisie "Fin d'étape". */
.save-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--trm-red-600);
  color: white;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.save-warning.hidden { display: none; }
.save-warning-icon { width: 20px; height: 20px; flex: none; }
.save-warning-text { flex: 1; }
.save-warning-close {
  flex: none;
  border: none;
  background: transparent;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.85;
}
.save-warning-close:hover { opacity: 1; }

/* La fenêtre Menu/Clubs a besoin de plus de largeur : cartes club > équipe
   > cycliste imbriquées, ça respire mieux plus large que les autres modales. */
#admin-backdrop .modal { max-width: 960px; }

.modal {
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 15px;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-body {
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Feuille d'étape en lecture seule, rejouée dans "Fin d'étape" pour garder
   une référence visuelle sous les yeux pendant la saisie des résultats. */
.end-stage-sheet-head {
  margin: 10px 16px 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}
.end-stage-sheet-wrap {
  max-height: 260px;
  margin: 6px 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.modal-note {
  margin: 10px 16px 0;
  padding: 8px 10px;
  background: var(--ref-bg);
  border-radius: 6px;
  font-size: 11px;
  color: var(--ink-soft);
}

.history-empty {
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

/* ---- Classement général ---- */
/* Les 4 maillots en un coup d'œil : une carte par classement, le leader
   du moment mis en avant avant le détail complet en tableau plus bas. */
.classement-leaders {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 540px) {
  .classement-leaders { grid-template-columns: repeat(4, 1fr); }
}

.leader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--ref-bg);
}

.leader-icon { font-size: 22px; line-height: 1; }
.leader-title {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.leader-name {
  margin-top: 5px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.leader-team {
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.leader-value {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 800;
}
.leader-empty {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-soft);
}

.leader-card--jaune { background: linear-gradient(180deg, #fff6d8, #fbe9a8); border-color: #e9cf6e; }
.leader-card--jaune .leader-value { color: #96770a; }
.leader-card--vert { background: linear-gradient(180deg, #e4f7e0, #c3ecb6); border-color: #9bd98a; }
.leader-card--vert .leader-value { color: #2e8b3d; }
.leader-card--pois {
  background:
    radial-gradient(rgba(192,57,43,0.28) 16%, transparent 17%) 0 0 / 18px 18px,
    linear-gradient(180deg, #fdeceb, #f9d9d5);
  border-color: #f0b3ac;
}
.leader-card--pois .leader-value { color: #b7392a; }
.leader-card--equipe { background: linear-gradient(180deg, #fdf1de, #f8dfad); border-color: #edc47e; }
.leader-card--equipe .leader-value { color: #a66d0d; }

:root[data-theme="dark"] .leader-card--jaune { background: linear-gradient(180deg, #3a3115, #2a2510); border-color: #6b5a1f; }
:root[data-theme="dark"] .leader-card--jaune .leader-value { color: #e8c353; }
:root[data-theme="dark"] .leader-card--vert { background: linear-gradient(180deg, #16301c, #102213); border-color: #2e5c3a; }
:root[data-theme="dark"] .leader-card--vert .leader-value { color: #7ed492; }
:root[data-theme="dark"] .leader-card--pois {
  background:
    radial-gradient(rgba(232,131,122,0.22) 16%, transparent 17%) 0 0 / 18px 18px,
    linear-gradient(180deg, #3a1c1a, #2a1413);
  border-color: #6b332d;
}
:root[data-theme="dark"] .leader-card--pois .leader-value { color: #e8837a; }
:root[data-theme="dark"] .leader-card--equipe { background: linear-gradient(180deg, #3a2c12, #2a2010); border-color: #6b4f1f; }
:root[data-theme="dark"] .leader-card--equipe .leader-value { color: #e0ad55; }

.leader-card--empty { opacity: 0.65; }

/* Un petit point de couleur par équipe, pour repérer un coureur d'un coup
   d'œil dans les tableaux — même palette que les en-têtes de la feuille. */
.team-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--ink-soft);
}
.team-dot[data-team="0"] { background: var(--team1); }
.team-dot[data-team="1"] { background: var(--team2); }
.team-dot[data-team="2"] { background: var(--team3); }
.team-dot[data-team="3"] { background: var(--team4); }

.classement-section-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.classement-section-icon { font-size: 15px; }
.classement-section-title { font-size: 13px; font-weight: 700; }
.classement-section-sub { font-size: 11px; color: var(--ink-soft); }

.classement-table-wrap {
  margin-top: 6px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 8px;
  overflow: hidden;
}
.classement-section--jaune .classement-table-wrap { border-left-color: #d9b03a; }
.classement-section--vert .classement-table-wrap { border-left-color: #4caf50; }
.classement-section--pois .classement-table-wrap { border-left-color: var(--danger); }
.classement-section--equipe .classement-table-wrap { border-left-color: #d59a3a; }

.classement-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.classement-table th, .classement-table td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.classement-table th {
  background: var(--ref-bg);
  color: var(--ink-soft);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}
.classement-table td.col-rank { text-align: center; font-weight: 700; width: 30px; }
.classement-table td.col-value { text-align: right; font-weight: 700; white-space: nowrap; }
.classement-table tbody tr:nth-child(even) { background: var(--ref-bg); }
.classement-table tbody tr.is-leader { background: var(--tier6); }
.classement-table tbody tr.is-leader td { font-weight: 700; }
.classement-table tbody tr:last-child td { border-bottom: none; }

.history-entry {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.history-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}

.history-stage-name {
  font-weight: 800;
  font-size: 15px;
}

.history-meta {
  font-size: 12px;
  color: var(--ink-soft);
}

.history-turns {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  background: var(--tier6);
  padding: 3px 9px;
  border-radius: 999px;
}

/* Petits badges inline pour les points sprint/montagne marqués sur l'étape,
   et pour l'écart au vainqueur — évite de tout entasser dans une phrase. */
.mini-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: var(--ref-bg);
  color: var(--ink-soft);
  white-space: nowrap;
}

.value-gap {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-soft);
}

.history-teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.history-team-name {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
}

.history-cyclist {
  font-size: 12px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 0;
}

/* Le badge PE reprend la palette des paliers PI de la feuille de route,
   pour repérer la fraîcheur d'un coup d'œil sans redire "PE" partout. */
.history-pe-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--ink);
  white-space: nowrap;
}
.history-cyclist.fatigued .history-pe-badge {
  box-shadow: inset 0 0 0 1.5px var(--danger);
  color: var(--danger);
}

.modal-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

/* ---- Menu (Partie Libre / Clubs) et administration (clubs, équipes,
   cyclistes, épreuves, étapes) ---- */
.menu-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--ref-bg);
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
/* Menu du site (voir sitebar plus bas) : les entrées sont des liens <a>,
   pas des boutons — même composant visuel, avec un état "page actuelle". */
.menu-entry.active {
  border-color: var(--primary);
  background: var(--tier6);
}
.menu-entry-icon-flat {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-entry-icon-flat svg { width: 20px; height: 20px; }
.menu-entry + .menu-entry { margin-top: 10px; }
.menu-entry-icon { display: flex; flex: none; line-height: 1; }
.menu-entry-icon svg { display: block; }
.menu-entry-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.menu-entry-title { font-size: 14px; font-weight: 800; }
.menu-entry-sub { font-size: 12px; color: var(--ink-soft); line-height: 1.3; }
.menu-entry-chevron { color: var(--ink-soft); font-size: 18px; flex: none; }

.admin-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 0;
}
.admin-tab-back {
  border: none;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 8px 7px 0;
  margin-right: 2px;
  cursor: pointer;
}
.admin-tab {
  border: none;
  background: var(--ref-bg);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.admin-tab.active { background: var(--primary); color: white; }

.admin-club-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 10px;
}
.admin-club-name {
  font-size: 15px;
  font-weight: 800;
  outline: none;
  min-width: 2em;
}
.admin-club-loc {
  font-size: 12px;
  color: var(--ink-soft);
  outline: none;
  min-width: 1.5em;
}
.admin-club-head .event-del { margin-left: auto; }

.admin-equipe-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--ref-bg);
  margin-top: 8px;
}
.admin-equipe-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.admin-equipe-name {
  font-size: 13px;
  font-weight: 700;
  outline: none;
  min-width: 2em;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 12px;
}
/* Nom : sa propre boîte bien visible, mais discrète — c'est le numéro qui
   prime pour repérer un coureur pendant la course. */
.admin-row-name {
  flex: 1;
  outline: none;
  min-width: 2em;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.admin-row-numero, .admin-row-pe {
  outline: none;
  min-width: 1.5em;
  text-align: center;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 11px;
}
/* Le numéro (dossard) est la donnée essentielle : pastille plus grande,
   en couleur, pour qu'il saute aux yeux avant le nom. */
.admin-row-numero {
  min-width: 2.2em;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  border-color: var(--primary);
}
.admin-row-numero::before { content: '#'; color: var(--ink-soft); font-weight: 700; }
.admin-row-pe::after { content: ' PE'; color: var(--ink-soft); font-weight: 400; }

.admin-add-row {
  margin-top: 8px;
}
.admin-empty {
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
  padding: 12px 0;
}

/* ---- Courses archivées : récap (réutilise classement/historique) + édition ---- */
.course-detail-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.course-edit-team + .course-edit-team { margin-top: 10px; }
.course-edit-cyclists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}
.course-edit-actions { display: flex; gap: 8px; }

.course-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.course-filter-search { flex: 1; min-width: 140px; }
.course-filter-sort { flex: none; width: auto; min-width: 0; }

/* ---- Panneau sprints / montagnes ---- */
.events-panel {
  margin: 0 10px 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.events-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.events-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.events-select {
  flex: 1;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  background: var(--ref-bg);
  color: var(--ink);
}

.events-points {
  width: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  background: var(--ref-bg);
  color: var(--ink);
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
}

.events-empty {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0;
}

.event-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 4px 8px;
  background: var(--ref-bg);
  border-radius: 6px;
}

.event-del {
  border: none;
  background: transparent;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
  flex: none;
}

/* ---- Fin d'étape : saisie des résultats ---- */
.endstage-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

.endstage-name {
  flex: 1;
  min-width: 140px;
  font-size: 13px;
  font-weight: 600;
}

.endstage-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--ink-soft);
}

.endstage-field input {
  width: 64px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 13px;
  background: var(--ref-bg);
  color: var(--ink);
}

/* ---- Barre légère des pages de contenu (Présentation / Règles / Le
   circuit / Les vélos) — plus sobre que .topbar (pas de champs de course),
   partagée par ces 4 pages + reprise en tête de feuille-etape.html pour
   donner accès au même menu de site. ---- */
.sitebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--topbar);
  color: var(--topbar-ink);
  border-bottom: 1px solid var(--line);
}
.sitebar .brand { text-decoration: none; cursor: pointer; }
.sitebar .brand-logo { height: 34px; width: auto; display: block; }

/* ---- Pages de contenu (prose) : Présentation, Règles, Le circuit, Les
   vélos — une colonne centrée de cartes, sur le même fond/thème que le
   reste de l'appli. ---- */
.content-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 16px 28px;
}

.content-hero {
  text-align: center;
  margin-bottom: 36px;
}
.content-hero-icon { font-size: 34px; line-height: 1; }
.content-hero-title {
  font-size: 22px;
  font-weight: 800;
  margin: 8px 0 6px;
}
.content-hero-sub {
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 42em;
  margin: 0 auto;
  line-height: 1.5;
}

.content-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.content-card h2 {
  font-size: 16px;
  margin: 0 0 10px;
  color: var(--primary);
}
.content-card h3 {
  font-size: 12px;
  margin: 16px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}
.content-card p { line-height: 1.6; margin: 0 0 10px; font-size: 14px; }
.content-card p:last-child { margin-bottom: 0; }
.content-card ul, .content-card ol { margin: 0 0 10px; padding-left: 1.3em; line-height: 1.6; font-size: 14px; }
.content-card table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.content-card table caption { text-align: left; font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.content-card table th, .content-card table td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; }
.content-card table th { background: var(--ref-bg); }

/* Marge haut/bas égale à celle de .content-card (22px) pour que l'espace
   soit le même de part et d'autre d'une rangée de boutons, qu'elle suive
   une carte ou en précède une (les marges adjacentes fusionnent en CSS). */
.content-cta-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 22px 0; }
.content-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}
.content-cta.secondary { background: var(--btn-bg); color: var(--trm-zinc-900); }
.content-cta:disabled, .content-cta[disabled] { opacity: 0.6; cursor: not-allowed; }

/* ---- Formulaire d'inscription newsletter ---- */
.subscribe-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.subscribe-form input {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ref-bg);
  color: var(--ink);
  font-size: 14px;
  font: inherit;
}
.subscribe-form input::placeholder { color: var(--trm-zinc-400); }
.subscribe-form input:focus { outline: none; border-color: var(--trm-zinc-500); }
.subscribe-form .content-cta { border: none; margin-top: 4px; }
.subscribe-msg { margin: 12px 0 0; font-size: 13px; text-align: center; min-height: 1em; }
.subscribe-msg.ok { color: #2e8b3d; }
.subscribe-msg.err { color: var(--danger); }

.credits-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 13px;
  color: var(--ink-soft);
}
.credits-row strong { color: var(--ink); }

/* Bouton "retour en haut", en bas des pages de contenu — même parti pris
   que sur Toi-Reviens-Moi (bibliothèque) : une pastille discrète après le
   dernier contenu, avant le pied de page. */
.back-to-top-row {
  display: flex;
  justify-content: center;
  margin: 8px 0 40px;
}
.back-to-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}
.back-to-top:hover { border-color: var(--ink-soft); background: var(--ref-bg); }
.back-to-top svg { width: 14px; height: 14px; }

/* Photos du jeu physique, récupérées de l'ancien site — une image pleine
   largeur avec légende, ou deux côte à côte. */
.content-photo {
  width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.content-photo-caption {
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
  margin: -8px 0 26px;
}
.content-photo-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 16px;
}
.content-photo-row .content-photo { margin-bottom: 0; }

/* Grand logo au-dessus du bandeau sur la page d'accueil : la version
   transparente se fond dans le fond clair, la version à fond blanc
   (utilisée aussi dans la barre de nav) se détache mieux du fond sombre. */
.home-logo {
  display: none;
  width: 160px;
  margin: 0 auto 16px;
}
.home-logo-light { display: block; }
:root[data-theme="dark"] .home-logo-light { display: none; }
:root[data-theme="dark"] .home-logo-dark { display: block; }

/* Bouton d'inscription transparent, calé sur le bouton "Restez informé(e)"
   déjà dessiné dans le bandeau (coordonnées relevées sur l'image source,
   774×256 : bouton entre x 533-712 et y 207-231, converties en %). */
.banner-wrap { position: relative; margin-bottom: 16px; }
.banner-wrap .content-photo { margin-bottom: 0; }
.banner-subscribe-btn {
  position: absolute;
  left: 68.9%;
  width: 23.1%;
  top: 80.5%;
  height: 9.8%;
  border-radius: 999px;
  cursor: pointer;
}

/* Pied de page "réalisé par M2R Studio" — pastille blanche fixe dans les
   deux thèmes (même parti pris que sur les autres sites du studio), logo
   martin-pêcheur en petit + lien vers m2r-studio.com. */
.site-footer {
  max-width: 720px;
  margin: 8px auto 0;
  padding: 0 16px 32px;
  display: flex;
  justify-content: center;
}
.m2r-credit {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.4;
}
.m2r-credit-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line);
  flex: none;
}

/* Grille de portraits (ex. "CycloSim, c'est qui ?") — même traitement que
   content-photo-row mais pensée pour 4 photos carrées. */
.team-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0 4px;
}
.team-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

