  :root {
    --bg: #1b1e24;
    --panel: #23272f;
    --panel2: #2b303a;
    --text: #d8dde6;
    --muted: #8a93a3;
    --accent: #4ea3ff;
    /* Les couleurs des câbles (4 par segment, jusqu'à 5 segments) sont définies en JS
       (GROUP_COLORS) et appliquées en styles inline sur les sliders/pastilles générés. */
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg);
    color: var(--text); font-family: "Segoe UI", system-ui, sans-serif; font-size: 13px; }
  #app { position: fixed; inset: 0; }
  #scene { position: absolute; inset: 0; }

  /* ---------- Panneau latéral ---------- */
  #panel {
    position: absolute; top: 0; left: 0; height: 100%; width: 320px;
    background: rgba(35,39,47,0.94); backdrop-filter: blur(6px);
    border-right: 1px solid #11141a; overflow-y: auto;
    transition: transform .25s ease; z-index: 10; padding: 14px 16px 40px;
  }
  #panel.collapsed { transform: translateX(-321px); }
  #togglePanel {
    position: absolute; top: 12px; left: 12px; z-index: 11;
    width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
    background: var(--panel); color: var(--text); border: 1px solid #11141a;
    font-size: 18px; line-height: 1; transition: left .25s ease;
  }
  #panel:not(.collapsed) ~ #togglePanel { left: 286px; }

  h1 { font-size: 15px; margin: 4px 0 2px; letter-spacing: .3px; }
  .sub { color: var(--muted); font-size: 11px; margin-bottom: 12px; }
  /* Onglets */
  .tabs { display: flex; gap: 6px; margin-bottom: 8px; }
  .tab { flex: 1; background: var(--panel2); color: var(--muted); border: 1px solid #11141a;
    border-radius: 7px; padding: 8px 4px; cursor: pointer; font-size: 13px; font-weight: 600; }
  .tab.active { background: var(--accent); color: #0d1b2a; border-color: var(--accent); }
  .colorrow { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
  .colorrow input[type=color] { width: 46px; height: 26px; border: 1px solid #11141a;
    border-radius: 6px; background: none; cursor: pointer; padding: 0; }
  .section { margin-bottom: 14px; border-top: 1px solid #11141a; padding-top: 10px; }
  .section h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
    color: var(--accent); margin: 0 0 8px; }
  .row { margin-bottom: 9px; }
  .row label { display: flex; justify-content: space-between; margin-bottom: 3px; }
  .row label .val { color: var(--muted); font-variant-numeric: tabular-nums; }
  input[type=range] { width: 100%; accent-color: var(--accent); }
  .cablerow input[type=range] { height: 16px; }
  .swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block;
    margin-right: 6px; vertical-align: middle; }
  h2 .seg { font-size: 10px; color: var(--muted); letter-spacing: 0; text-transform: none; }
  /* Presets de pose */
  .presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
  .presets button { background: var(--panel2); color: var(--text); border: 1px solid #11141a;
    border-radius: 6px; padding: 7px 6px; cursor: pointer; font-size: 12px; }
  .presets button:hover { background: #343b47; }
  .cmp { display: flex; align-items: center; gap: 6px; background: var(--panel2);
    padding: 6px 8px; border-radius: 6px; cursor: pointer; margin-bottom: 8px; font-size: 12px; }
  .toggles { display: flex; flex-wrap: wrap; gap: 6px; }
  .toggles label { display: flex; align-items: center; gap: 5px; background: var(--panel2);
    padding: 5px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; }
  button.act { background: var(--panel2); color: var(--text); border: 1px solid #11141a;
    border-radius: 6px; padding: 7px 10px; cursor: pointer; width: 100%; font-size: 13px; }
  button.act:hover { background: #343b47; }

  /* ---------- Panneau servos (droite) ---------- */
  #servoPanel {
    position: absolute; top: 0; right: 0; height: 100%; width: 280px;
    background: rgba(35,39,47,0.94); backdrop-filter: blur(6px);
    border-left: 1px solid #11141a; overflow-y: auto;
    transition: transform .25s ease; z-index: 10; padding: 14px 16px 40px;
  }
  #servoPanel.collapsed { transform: translateX(281px); }
  #toggleServo {
    position: absolute; top: 12px; right: 12px; z-index: 11;
    width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
    background: var(--panel); color: var(--text); border: 1px solid #11141a;
    font-size: 16px; line-height: 1; transition: right .25s ease;
  }
  #servoPanel h1, #servoPanel .sub { margin-right: 40px; } /* laisse la place au bouton */

  /* ---------- Barre de lecture d'animation (haut) ---------- */
  #playbar {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 12px; z-index: 11;
    background: rgba(35,39,47,0.92); backdrop-filter: blur(6px);
    border: 1px solid #11141a; border-radius: 12px; padding: 7px 12px;
    transition: opacity .2s ease;
  }
  #playbar.inactive { opacity: .6; }
  #playPause {
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer; flex: none;
    background: var(--accent); color: #0d1b2a; border: none; font-size: 13px; line-height: 1;
  }
  #playbar.paused #playPause, #playbar.inactive #playPause { background: var(--panel2); color: var(--text); }
  .pb-name { font-size: 12px; font-weight: 600; color: var(--text);
    min-width: 78px; text-align: center; }
  .pb-speed { display: flex; align-items: center; gap: 8px; }
  .pb-speed .pb-lbl { font-size: 11px; color: var(--muted); }
  .pb-speed input[type=range] { width: 130px; }
  .pb-speed .val { font-size: 11px; color: var(--muted);
    font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }

  /* ---------- Barre de joysticks (bas) ---------- */
  #joyBar {
    position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 14px; align-items: flex-end; z-index: 9;
    background: rgba(35,39,47,0.92); backdrop-filter: blur(6px);
    border: 1px solid #11141a; border-radius: 14px; padding: 10px 14px 8px;
  }
  .joyCell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .joyCell .cap { font-size: 11px; color: var(--muted); }
  .joyCell .cap b { color: var(--text); }
  .joypad { width: 110px; height: 110px; touch-action: none; cursor: pointer;
    background: var(--panel2); border-radius: 50%; border: 1px solid #11141a; flex: none; }

  /* ---------- Lecture câbles ---------- */
  #readout { font-variant-numeric: tabular-nums; font-size: 12px; }
  #readout .line { display: flex; justify-content: space-between; padding: 2px 0; }
  #hud { position: absolute; bottom: 10px; right: 12px; z-index: 9; color: var(--muted);
    font-size: 11px; text-align: right; line-height: 1.5; }
  #hud b { color: var(--text); }
