:root {
  --fond: #0a0f1e;
  --fond-2: #0e1528;
  --carte: #111a30;
  --bord: #1e2a47;
  --texte: #e6ecf8;
  --texte-2: #8b97b0;
  --accent: #7c8cf8;
  --accent-fort: #98a6ff;
  --gauche: #38bdf8;
  --droit: #fb923c;
  --bassin: #94a3b8;
  --vert: #34d399;
  --rouge: #f87171;
  --jaune: #fbbf24;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Inter", sans-serif;
  font-size: 14px;
  color: var(--texte);
  background: var(--fond);
}

body {
  display: grid;
  grid-template-columns: 250px 1fr 310px;
  height: 100vh;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
h1, h2, h3, p { margin: 0; }

/* ---------- Colonne gauche : sujets ---------- */

.barre {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 14px;
  background: var(--fond-2);
  border-right: 1px solid var(--bord);
  min-height: 0;
}

.marque { display: flex; gap: 10px; align-items: center; }
.logo {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #0a0f1e;
  font-weight: 700; font-size: 18px;
}
.marque h1 { font-size: 17px; font-weight: 700; }
.marque p { font-size: 11.5px; color: var(--texte-2); }

.section-titre {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--texte-2);
  margin-top: 6px;
}

.arbre { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; min-height: 60px; }

.sujet-bloc { margin-bottom: 10px; }

.sujet-ligne, .visite-ligne, .essai-ligne {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
}
.sujet-ligne > span:first-child,
.visite-ligne > span:first-child,
.essai-ligne > span:first-child { white-space: nowrap; }

.sujet-ligne { font-weight: 600; }
.visite-ligne { color: var(--texte-2); font-size: 13px; padding-left: 18px; }
.essai-ligne {
  width: 100%;
  border: none;
  background: none;
  color: var(--texte);
  text-align: left;
  padding-left: 32px;
  font-size: 13.5px;
}
.essai-ligne:hover { background: #16203a; }
.essai-ligne.actif { background: #1c2745; box-shadow: inset 2px 0 0 var(--accent); }

.badge {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: #1c2745;
  color: var(--texte-2);
}
.badge.vert { background: rgba(52, 211, 153, 0.15); color: var(--vert); }
.badge.jaune { background: rgba(251, 191, 36, 0.15); color: var(--jaune); }

.pousse { flex: 1 0 auto; }

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 14px;
}
.carte h2 { font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }

.param { display: flex; justify-content: space-between; padding: 3px 0; color: var(--texte-2); }
.param strong { color: var(--texte); font-variant-numeric: tabular-nums; }

.bouton {
  border: none;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  color: #0a0f1e;
}
.bouton:hover { background: var(--accent-fort); }
.bouton.contour {
  background: none;
  border: 1px solid var(--bord);
  color: var(--texte);
}
.bouton.contour:hover { border-color: var(--accent); }
.bouton.secondaire { background: #1c2745; color: var(--texte); }
.bouton.large { width: 100%; }

#formulaire-sujet { display: flex; flex-direction: column; gap: 8px; }
#formulaire-sujet input {
  background: var(--fond);
  border: 1px solid var(--bord);
  border-radius: 8px;
  color: var(--texte);
  padding: 7px 10px;
  font-family: inherit;
}
.ligne-boutons { display: flex; gap: 8px; }
.ligne-boutons .bouton { flex: 1; padding: 6px 8px; }

/* ---------- Colonne centrale ---------- */

.principal {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
}
.entete-titre h2 { font-size: 17px; font-weight: 700; }
.entete-titre p { font-size: 12.5px; color: var(--texte-2); margin-top: 2px; }
.entete-actions { display: flex; gap: 10px; }
.bouton.principal { background: var(--accent-fort); }

.vue {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 20px;
  border-radius: 14px;
  overflow: hidden;
  background: #070b16;
  border: 1px solid var(--bord);
}
#vue3d { width: 100%; height: 100%; display: block; touch-action: none; }

.vide-vue {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--texte-2);
  pointer-events: none;
}

.infos {
  position: absolute;
  top: 14px; left: 14px;
  background: rgba(10, 15, 30, 0.82);
  border: 1px solid var(--bord);
  border-radius: 10px;
  padding: 10px 14px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
}
.infos-titre { display: flex; gap: 10px; font-size: 14px; }
.infos-titre span { color: var(--texte-2); }
.infos-pied { font-size: 13px; color: var(--texte-2); }
.infos-pied .etat { font-weight: 600; }
.etat.sol { color: var(--vert); }
.etat.leve { color: var(--rouge); }

.legende {
  position: absolute;
  top: 14px; right: 14px;
  display: flex;
  gap: 14px;
  background: rgba(10, 15, 30, 0.82);
  border: 1px solid var(--bord);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
}
.cle { display: inline-flex; align-items: center; gap: 6px; }
.puce { width: 10px; height: 10px; border-radius: 50%; }
.puce.gauche { background: var(--gauche); }
.puce.droit { background: var(--droit); }
.puce.bassin { background: var(--bassin); }

/* ---------- Barre de lecture ---------- */

.lecture {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px 4px;
}
.transport { display: flex; align-items: center; gap: 6px; }
.transport button {
  border: 1px solid var(--bord);
  background: none;
  color: var(--texte);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
}
.transport button:hover { border-color: var(--accent); }
.transport .rond {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #0a0f1e;
  font-size: 15px;
}
.transport .rond:hover { background: var(--accent-fort); }

.temps {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
  min-width: 84px;
  text-align: center;
}

.vitesses { display: flex; gap: 4px; margin-left: auto; }
.vitesses button {
  border: 1px solid transparent;
  background: none;
  color: var(--texte-2);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12.5px;
}
.vitesses button:hover { color: var(--texte); }
.vitesses button.actif { border-color: var(--accent); color: var(--texte); }

/* ---------- Pistes ---------- */

.piste { padding: 8px 20px 16px; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 0 0 8px;
}

.pistes-pieds { display: flex; flex-direction: column; gap: 6px; }
.ligne-piste { display: flex; align-items: center; gap: 10px; }
.ligne-piste .nom {
  width: 16px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.ligne-piste:first-child .nom { color: var(--gauche); }
.ligne-piste:last-child .nom { color: var(--droit); }

.rail {
  position: relative;
  flex: 1;
  height: 26px;
  background: var(--fond-2);
  border: 1px solid var(--bord);
  border-radius: 8px;
  overflow: hidden;
}

.appui {
  position: absolute;
  top: 3px; bottom: 3px;
  border-radius: 5px;
  opacity: 0.35;
}
.rail-g .appui { background: var(--gauche); }
.rail-d .appui { background: var(--droit); }

.marqueur-piste {
  position: absolute;
  top: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #0a0f1e;
  border-radius: 50%;
  cursor: ew-resize;
  z-index: 2;
}
.marqueur-piste.pose { border-radius: 4px 50% 50% 50%; }
.marqueur-piste.lever { border-radius: 50% 50% 50% 4px; }
.rail-g .marqueur-piste { background: var(--gauche); }
.rail-d .marqueur-piste { background: var(--droit); }

.curseur-piste {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--texte);
  opacity: 0.7;
  pointer-events: none;
  z-index: 3;
}

/* ---------- Colonne droite : événements ---------- */

.colonne {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 16px;
  background: var(--fond-2);
  border-left: 1px solid var(--bord);
  overflow-y: auto;
}

.carte-titre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.carte-titre h2 { margin: 0; }
.compte {
  font-size: 12px;
  font-weight: 600;
  color: var(--texte-2);
  background: #1c2745;
  padding: 2px 9px;
  border-radius: 999px;
}

.boutons-events {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bouton-event {
  border: 1px solid var(--bord);
  background: none;
  color: var(--texte);
  border-radius: 9px;
  padding: 8px 6px;
  font-size: 12.5px;
  font-weight: 600;
}
.bouton-event:hover { border-color: var(--accent); background: #16203a; }
#btn-pose-g, #btn-lever-g { color: var(--gauche); }
#btn-pose-d, #btn-lever-d { color: var(--droit); }

.actions-secondaires { display: flex; gap: 8px; margin-top: 8px; }
.mini {
  flex: 1;
  border: 1px dashed var(--bord);
  background: none;
  color: var(--texte-2);
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 11.5px;
}
.mini:hover { color: var(--texte); border-color: var(--accent); }

.liste-events {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 44vh;
  overflow-y: auto;
}
.evenement {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
.evenement:hover { background: #16203a; }
.evenement .icone { width: 16px; text-align: center; font-size: 11px; }
.evenement.gauche .icone { color: var(--gauche); }
.evenement.droit .icone { color: var(--droit); }
.evenement .libelle { font-weight: 600; width: 58px; }
.evenement .detail { flex: 1; color: var(--texte-2); }
.evenement .actions-mini { display: flex; gap: 2px; }
.evenement .actions-mini button {
  border: none;
  background: none;
  color: var(--texte-2);
  padding: 2px 5px;
  border-radius: 6px;
  font-size: 12px;
}
.evenement .actions-mini button:hover { color: var(--texte); background: #1c2745; }

.liste-vide { color: var(--texte-2); font-size: 12.5px; padding: 8px; }

.message { min-height: 18px; font-size: 12.5px; margin-top: 6px; }
.message.erreur { color: var(--rouge); }
.message.succes { color: var(--vert); }

.raccourcis { color: var(--texte-2); font-size: 12.5px; }
.raccourci { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.touche {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  background: var(--fond);
  border: 1px solid var(--bord);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--texte);
  font-variant-numeric: tabular-nums;
}
