/* ABORUN — feuille de style unique
   Sombre par défaut : l'app vit dans un habitacle, souvent de nuit. */

:root {
  --bg: #0b0d10;
  --bg-2: #12161c;
  --bg-3: #1a2029;
  --line: #262f3a;
  --ink: #e9eef5;
  --ink-2: #9aa7b8;
  --ink-3: #64707f;

  --green: #12c66a;
  --blue: #2f7bff;
  --orange: #ff8a1f;
  --red: #ff2233;

  --accent: #ff8a1f;
  --radius: 14px;
  --radius-lg: 20px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

/* overflow-x: clip et non hidden : hidden sur html/body casse position:sticky */
body { overflow-x: clip; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app { display: block; }

.screen {
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 28px) calc(var(--safe-l) + 16px);
  max-width: 720px;
  margin: 0 auto;
  animation: fade .18s ease-out;
}

@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

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

/* ---------------- Barre d'app ---------------- */

.appbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  margin-bottom: 8px;
}

.appbar__logo { font-weight: 800; letter-spacing: .16em; font-size: 13px; color: var(--accent); }
.appbar__title { font-size: 17px; font-weight: 650; margin: 0; flex: 1; }
.appbar__actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

.appbar__back {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 19px; line-height: 1;
}

/* ---------------- Indicateur de connexion ---------------- */

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--bg-2);
  white-space: nowrap;
}

.conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }

.conn--online { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.conn--online .conn__dot { background: var(--green); }

.conn--connecting { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 55%, transparent); }
.conn--connecting .conn__dot { background: var(--orange); animation: pulse .8s infinite; }

.conn--offline {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}
.conn--offline .conn__dot { background: #fff; animation: pulse .6s infinite; }

.conn--idle { color: var(--ink-3); }

@keyframes pulse { 50% { opacity: .25; } }

/* ---------------- Accueil ---------------- */

.hero { padding: 28px 0 22px; }
.hero__mark {
  font-size: clamp(2.6rem, 15vw, 4.2rem);
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: .95;
  background: linear-gradient(100deg, #fff 20%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__tag { color: var(--ink-2); margin: 10px 0 0; font-size: 14px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack--tight { gap: 10px; }

.row { display: flex; gap: 12px; }
.row--2 > * { flex: 1; min-width: 0; }
.row--split { align-items: center; justify-content: space-between; }
.row--add { align-items: stretch; }
.row--add .input { flex: 1; min-width: 0; }

/* ---------------- Boutons ---------------- */

.btn {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-weight: 650;
  font-size: 15px;
  transition: transform .06s ease, background .15s ease;
  text-align: center;
}
.btn:active { transform: scale(.985); }

.btn--hero {
  background: linear-gradient(180deg, var(--accent), #e5740f);
  border-color: transparent;
  color: #14100a;
  font-size: 18px;
  font-weight: 800;
  padding: 20px;
  letter-spacing: .01em;
}

.btn--big { padding: 18px; font-size: 16px; }
.btn--primary { background: var(--blue); border-color: transparent; color: #fff; }
.btn--danger { background: var(--red); border-color: transparent; color: #fff; }
.btn--danger-ghost { color: #ff8b95; border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--sm { padding: 8px 13px; font-size: 13px; border-radius: 10px; }

.btn--sticky {
  position: sticky;
  bottom: calc(var(--safe-b) + 12px);
  margin-top: 14px;
  box-shadow: 0 10px 30px rgb(0 0 0 / .5);
}

.iconbtn {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 32px; height: 32px;
  font-size: 15px; line-height: 1;
  color: var(--ink-2);
}
.iconbtn--del { color: #ff8b95; }

/* ---------------- Panneaux, champs ---------------- */

.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel--flush { padding: 0; overflow: hidden; }
.panel__title { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.panel__kicker { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field__hint, .hint { font-size: 12px; color: var(--ink-3); line-height: 1.45; margin: 0; }
.hint--ok { color: var(--green); }
.hint--warn { color: var(--orange); }
.hint--nudge { text-align: center; }

.input {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px 14px;
  width: 100%;
  min-width: 0;
  appearance: none;
  font-size: 16px; /* < 16px déclenche le zoom automatique sur iOS */
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.input--inline { width: auto; }
.input--code { font-family: var(--mono); letter-spacing: .1em; text-align: center; font-size: 20px; }

select.input {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: right 17px center, right 12px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.code {
  font-family: var(--mono);
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--accent);
}
.code__desc { font-size: 13px; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips--filter { margin-bottom: 12px; }
.chip {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.chip--on { background: var(--accent); border-color: transparent; color: #14100a; }

/* ---------------- Choix de rôle ---------------- */

.roles { display: flex; flex-direction: column; gap: 9px; }
.role {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  background: var(--bg-3);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.role--on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-3)); }
.role__title { font-weight: 750; font-size: 16px; }
.role__desc { font-size: 12.5px; color: var(--ink-2); }

/* ---------------- Cartes accueil ---------------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card--live { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--bg-2)); }
.card__kicker { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.card--live .card__kicker { color: var(--green); }
.card__title { font-family: var(--mono); font-size: 19px; font-weight: 700; }
.card__sub { font-size: 12.5px; color: var(--ink-2); }

/* =========================================================
   ÉCRAN OUVREUR — la télécommande
   ========================================================= */

body[data-screen='opener'] { overflow: hidden; }

.screen--opener {
  height: 100dvh;
  max-width: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg);
  flex: none;
}
.bar--top { padding-top: calc(var(--safe-t) + 8px); }
.bar--bottom { padding-bottom: calc(var(--safe-b) + 8px); }
.bar__code { font-family: var(--mono); letter-spacing: .08em; color: var(--ink); }
.bar__link { margin-left: auto; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 11px; color: var(--green); }
.bar__link--bad { color: #fff; background: var(--red); padding: 3px 9px; border-radius: 999px; animation: pulse .7s infinite; }
.bar__peers { font-weight: 600; }
.bar__peers--alone { color: var(--orange); }
.bar__mid { margin-left: auto; margin-right: auto; font-family: var(--mono); font-size: 15px; color: var(--ink); }
.bar__speed { font-weight: 700; }
.bar__quit { margin-left: auto; background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; color: var(--ink-2); font-size: 12px; }

.grid--flags {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 5px;
  padding: 0 5px 5px;
  min-height: 0;
}

.flagbtn {
  border: 4px solid transparent;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  opacity: .48;
  transition: opacity .1s linear, border-color .1s linear, filter .1s linear;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.flagbtn__label {
  font-size: clamp(1rem, 5.5vw, 1.9rem);
  font-weight: 900;
  letter-spacing: .06em;
  color: #08090b;
  text-shadow: 0 1px 0 rgb(255 255 255 / .25);
}
.flagbtn--green  { background: var(--green); }
.flagbtn--blue   { background: var(--blue); }
.flagbtn--orange { background: var(--orange); }
.flagbtn--red    { background: var(--red); }
.flagbtn--blue .flagbtn__label,
.flagbtn--red .flagbtn__label { color: #fff; text-shadow: 0 1px 2px rgb(0 0 0 / .35); }

.flagbtn--on { opacity: 1; border-color: #fff; }
.flagbtn:active { filter: brightness(1.18); }

.grid--offline { filter: grayscale(.55); }
.grid--failed { outline: 3px solid var(--red); outline-offset: -3px; }

/* =========================================================
   ÉCRAN PILOTE — le panneau
   ========================================================= */

body[data-screen='driver'] { overflow: hidden; }

.screen--driver {
  position: fixed;
  inset: 0;
  padding: 0;
  max-width: none;
  animation: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.panel-flag {
  position: absolute;
  inset: 0;
  background: var(--green);
  /* Transition quasi instantanée : l'information ne doit jamais traîner. */
  transition: background-color 80ms linear;
}
.panel-flag[data-flag='green']  { background: var(--green); }
.panel-flag[data-flag='blue']   { background: var(--blue); }
.panel-flag[data-flag='orange'] { background: var(--orange); }
.panel-flag[data-flag='red']    { background: var(--red); }

/* Mode nuit : désaturé, pour ne pas éblouir dans l'habitacle. */
.screen--driver.is-night .panel-flag { filter: brightness(.58) saturate(.8); }

/* --- Perte de liaison : impossible à confondre avec du vert --- */
.lost {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #0b0d10;
  z-index: 2;
}
.screen--driver.is-lost .lost { display: flex; animation: lostblink 1.1s steps(1) infinite; }
.screen--driver.is-lost .panel-flag { filter: grayscale(1) brightness(.35); }

@keyframes lostblink { 50% { background: #2a0f12; } }

.lost__stripes {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, #ff2233 0 28px, #0b0d10 28px 56px);
  opacity: .28;
}
.lost__text {
  position: relative;
  font-size: clamp(2.4rem, 14vw, 6rem);
  font-weight: 900;
  letter-spacing: .04em;
  text-align: center;
  line-height: .95;
  color: #fff;
  text-shadow: 0 4px 24px rgb(0 0 0 / .8);
}

/* --- Appui long pour sortir --- */
.hold {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 6px;
  z-index: 3;
  opacity: 0;
  transition: opacity .12s;
}
.hold--on { opacity: 1; }
.hold__fill {
  height: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
  mix-blend-mode: difference;
}

.driver-controls {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgb(4 6 8 / .88);
  backdrop-filter: blur(8px);
  padding: 24px;
}
.screen--driver.is-open .driver-controls { display: flex; }
.driver-controls__box {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.driver-controls__code { font-family: var(--mono); font-size: 17px; color: var(--ink-2); letter-spacing: .08em; }
.driver-controls__time { font-family: var(--mono); font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* =========================================================
   ÉCRAN COPILOTE
   ========================================================= */

.banner {
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  font-size: clamp(1.3rem, 7vw, 2rem);
  font-weight: 900;
  letter-spacing: .1em;
  color: #08090b;
  margin-bottom: 12px;
  transition: background-color 80ms linear;
}
.banner[data-flag='green']  { background: var(--green); }
.banner[data-flag='blue']   { background: var(--blue); color: #fff; }
.banner[data-flag='orange'] { background: var(--orange); }
.banner[data-flag='red']    { background: var(--red); color: #fff; }
.banner--lost {
  background: repeating-linear-gradient(45deg, #ff2233 0 16px, #0b0d10 16px 32px) !important;
  color: #fff !important;
  animation: pulse 1s infinite;
}

.grid--stats {
  display: grid;
  /* 140px : deux colonnes sur mobile (2×2 équilibré), quatre au-delà. */
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}
.stat__value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums; /* pas de saut de layout quand la valeur change */
  line-height: 1.1;
}
.stat__unit { font-size: 12px; color: var(--ink-3); margin-left: 2px; font-weight: 500; }
.stat__label { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; margin-top: 4px; }

.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.note {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  line-height: 1.35;
}
.notes--edit .note:last-child, .panel--flush .note:last-child { border-bottom: none; }
.note--done { opacity: .4; text-decoration: line-through; }
.note--empty { color: var(--ink-3); font-size: 13px; justify-content: center; }
.note__idx {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.note__text { flex: 1; min-width: 0; }
.note__tools { display: flex; gap: 5px; flex: none; }

.map { display: block; width: 100%; height: 220px; background: var(--bg-3); }
.map--detail { height: 300px; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 12px; }
.map--empty, .map--failed {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-size: 13px;
  height: 120px;
}

.pin span {
  display: block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgb(0 0 0 / .6);
  background: var(--ink-3);
}
.pin--self span { background: var(--accent); }
.pin--opener span { background: var(--blue); }
.pin--driver span { background: var(--green); }
.pin--copilot span { background: #b06bff; }

.peers { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; }
.peer {
  font-size: 11.5px;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.peer--opener { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.peer--driver { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.peer--copilot { color: #b06bff; border-color: #4b2d75; }

.backup { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.backup__btn {
  border: none;
  border-radius: 10px;
  padding: 14px 4px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .04em;
  color: #08090b;
  opacity: .78;
}
.backup__btn--green { background: var(--green); }
.backup__btn--blue { background: var(--blue); color: #fff; }
.backup__btn--orange { background: var(--orange); }
.backup__btn--red { background: var(--red); color: #fff; }
.backup__btn:active { opacity: 1; }

/* =========================================================
   HISTORIQUE
   ========================================================= */

.runcard {
  display: flex;
  align-items: stretch;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.runcard--sel { border-color: var(--accent); }
.runcard__main {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  text-align: left;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.runcard__code { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--accent); }
.runcard__date { font-size: 12px; color: var(--ink-3); }
.runcard__stats { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.runcard__cond { font-size: 11.5px; color: var(--ink-3); }
.runcard__pick {
  flex: none;
  width: 52px;
  background: var(--bg-3);
  border: none;
  border-left: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 18px;
}
.runcard--sel .runcard__pick { background: var(--accent); color: #14100a; }

.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px; align-items: center; }

.deflist { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.deflist__row { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.deflist dt { color: var(--ink-3); margin: 0; }
.deflist dd { margin: 0; font-weight: 600; }

.flaglog { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.flaglog__item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 9px;
  background: var(--bg-3);
  font-size: 13px;
  border-left: 4px solid var(--ink-3);
}
.flaglog__item--green { border-left-color: var(--green); }
.flaglog__item--blue { border-left-color: var(--blue); }
.flaglog__item--orange { border-left-color: var(--orange); }
.flaglog__item--red { border-left-color: var(--red); }
.flaglog__t { font-family: var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.flaglog__f { font-weight: 750; letter-spacing: .05em; }
.flaglog__by { color: var(--ink-3); font-size: 11.5px; }

/* --- Comparaison --- */

.cmp-head { display: flex; align-items: center; gap: 12px; text-align: center; }
.cmp-head__col { flex: 1; min-width: 0; }
.cmp-head__code { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--accent); word-break: break-all; }
.cmp-head__date { font-size: 11.5px; color: var(--ink-3); }
.cmp-head__vs { color: var(--ink-3); font-size: 12px; font-weight: 700; }

.cmp {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.cmp:last-child { border-bottom: none; }
.cmp__a { text-align: right; font-weight: 650; font-size: 15px; }
.cmp__b { text-align: left; font-weight: 650; font-size: 15px; }
.cmp__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
  text-align: center;
  min-width: 78px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cmp__delta { font-size: 10.5px; color: var(--ink-2); letter-spacing: 0; }
.cmp--win { color: var(--green); }
.cmp--cond { padding: 9px 14px; font-size: 13px; }
.cmp--diff { background: color-mix(in srgb, var(--orange) 9%, transparent); }
.cmp--cond .cmp__a, .cmp--cond .cmp__b { font-size: 13px; font-weight: 500; }

.idline__wrap { display: flex; flex-direction: column; gap: 6px; }
.idline { font-family: var(--mono); font-size: 11px; color: var(--ink-3); word-break: break-all; }

.legal { font-size: 11px; color: var(--ink-3); line-height: 1.5; text-align: center; margin: 8px 0 0; }

/* =========================================================
   ROUTES, PROFILS, SOLO
   ========================================================= */

.row--3 > * { flex: 1; min-width: 0; }
.row--3 .btn { padding: 13px 6px; font-size: 13.5px; }

.btn--solo { border-color: color-mix(in srgb, #b06bff 45%, transparent); color: #d3b3ff; }

.input--area { resize: vertical; min-height: 76px; line-height: 1.45; font-family: inherit; }

.roles--row { flex-direction: row; }
.roles--row .role { flex: 1; min-width: 0; }

.card__title--plain { font-family: var(--font); font-size: 17px; }

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge--solo { color: #d3b3ff; border-color: #4b2d75; }
.badge--group { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.badge--gold { color: #f5c451; border-color: #6b5313; background: #241d08; }

.runcard__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- Classement d'une route --- */

.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board__row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  grid-template-areas: 'rank name time' '. meta meta';
  gap: 2px 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.board__row--first { border-color: #6b5313; background: #1b1708; }
.board__rank { grid-area: rank; font-weight: 800; color: var(--ink-3); text-align: center; }
.board__row--first .board__rank { color: #f5c451; }
.board__name {
  grid-area: name;
  background: none; border: none; padding: 0;
  text-align: left; font-weight: 650; font-size: 15px; color: var(--ink);
}
.board__name:disabled { color: var(--ink-2); cursor: default; }
.board__time { grid-area: time; font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.board__meta { grid-area: meta; font-size: 11px; color: var(--ink-3); }

/* --- Identité d'un pilote --- */

.panel--ident { gap: 14px; }
.ident { display: flex; align-items: center; gap: 14px; }
.ident__avatar {
  width: 56px; height: 56px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 800;
  color: #14100a;
  background: linear-gradient(140deg, var(--accent), #ffd08a);
}
.ident__name { font-size: 20px; font-weight: 750; }
.ident__handle { font-family: var(--mono); font-size: 13px; color: var(--accent); }
.ident__cars { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.split { display: flex; align-items: stretch; gap: 12px; }
.split__col { flex: 1; min-width: 0; text-align: center; }
.split__sep { width: 1px; background: var(--line); flex: none; }
.split__label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.split__big { font-family: var(--mono); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0; }
.split__meta { font-size: 12px; color: var(--ink-2); }

.routerow {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
}
.routerow__head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.routerow__letter {
  width: 26px; height: 26px; flex: none;
  border-radius: 8px;
  background: var(--accent); color: #14100a;
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px;
}
.routerow__name { font-weight: 650; font-size: 15px; }
.routerow__stats { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.routerow__date { font-size: 11px; color: var(--ink-3); }

.minilist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.minilist__btn {
  width: 100%;
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-areas: 'code badge date' 'meta meta meta';
  gap: 3px 9px;
  align-items: center;
  text-align: left;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
}
.minilist__code { grid-area: code; font-family: var(--mono); font-weight: 700; color: var(--accent); }
.minilist__btn .badge { grid-area: badge; }
.minilist__date { grid-area: date; text-align: right; font-size: 11px; color: var(--ink-3); }
.minilist__meta { grid-area: meta; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.friend { display: flex; align-items: center; gap: 8px; }
.friend__main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  text-align: left;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.friend__name { font-weight: 650; }
.friend__meta { font-size: 11.5px; color: var(--ink-3); }

/* --- Run solo --- */

.solo-badge {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  color: #d3b3ff;
  background: #1a1230;
  border: 1px solid #4b2d75;
  border-radius: 999px;
  padding: 5px 12px;
  margin: 0 auto 12px;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speedo {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-align: center;
}
.speedo__value {
  font-family: var(--mono);
  font-size: clamp(4rem, 26vw, 7rem);
  font-weight: 700;
  line-height: .95;
  font-variant-numeric: tabular-nums;
}
.speedo__unit { font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }

.stat--warn { border-color: color-mix(in srgb, var(--orange) 55%, transparent); }
.stat--warn .stat__value { color: var(--orange); }

/* ---------------- Toasts & modale ---------------- */

.toasts {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--safe-b) + 16px);
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  max-width: 460px;
  box-shadow: 0 12px 32px rgb(0 0 0 / .6);
  animation: toastin .2s ease-out;
}
.toast--out { opacity: 0; transition: opacity .3s; }
.toast--ok { border-color: var(--green); color: var(--green); }
.toast--warn { border-color: var(--orange); color: var(--orange); }
.toast--error { background: var(--red); border-color: var(--red); color: #fff; }

@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgb(4 6 8 / .78);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal__box {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal__title { margin: 0; font-size: 18px; }
.modal__text { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.modal__actions { display: flex; gap: 10px; margin-top: 4px; }
.modal__actions .btn { flex: 1; }

/* Leaflet : accorder les contrôles au thème sombre */
.leaflet-container { background: var(--bg-3); font-family: var(--font); }
.leaflet-control-attribution {
  background: rgb(11 13 16 / .8) !important;
  color: var(--ink-3) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--ink-2) !important; }
