:root {
  --bg: #05080d;
  --bg-soft: #090f18;
  --panel: rgba(14, 22, 34, 0.88);
  --panel-strong: #0d1622;
  --line: rgba(148, 177, 204, 0.14);
  --line-strong: rgba(148, 177, 204, 0.26);
  --ink: #e7eef7;
  --muted: #8ea0b5;
  --faint: #5f7186;
  --accent: #5eead4;
  --accent-2: #38bdf8;
  --accent-dim: rgba(94, 234, 212, 0.12);
  --amber: #fbbf24;
  --danger: #ff4d6d;
  --danger-dim: rgba(255, 77, 109, 0.12);
  --violet: #c084fc;
  --radius: 18px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(56, 189, 248, 0.14), transparent 62%),
    radial-gradient(900px 520px at 100% 0%, rgba(94, 234, 212, 0.1), transparent 55%),
    radial-gradient(800px 600px at 50% 120%, rgba(192, 132, 252, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(148, 177, 204, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 177, 204, 0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 78%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #04110e;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 2.4vw, 32px) 28px;
}

/* ── Barre supérieure ─────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(7, 12, 19, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 50px -40px #000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(94, 234, 212, 0.35);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(94, 234, 212, 0.16), rgba(56, 189, 248, 0.04));
  box-shadow: inset 0 0 18px rgba(94, 234, 212, 0.12);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-mark path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-text {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.brand-text em {
  font-style: normal;
  color: var(--accent);
  font-weight: 600;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(9, 15, 24, 0.7);
}

.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.pill[data-state="online"] {
  color: var(--accent);
  border-color: rgba(94, 234, 212, 0.38);
  background: rgba(94, 234, 212, 0.08);
}

.pill[data-state="offline"] {
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.32);
  background: rgba(251, 191, 36, 0.07);
}

.pill[data-state="demo"] {
  color: var(--violet);
  border-color: rgba(192, 132, 252, 0.38);
  background: rgba(192, 132, 252, 0.09);
}

.metrics {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0;
}

.metric dt {
  margin: 0 0 2px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.metric dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink);
  white-space: nowrap;
}

.metric dd.is-low {
  color: var(--danger);
}

.metric dd.is-ok {
  color: var(--accent);
}

/* ── Boutons ──────────────────────────────────────────────────────────── */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(16, 25, 38, 0.8);
  color: var(--ink);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 120ms ease;
}

.btn:hover {
  border-color: rgba(94, 234, 212, 0.45);
  background: rgba(94, 234, 212, 0.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
button:focus-visible,
input:focus-visible,
.joystick:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-ghost {
  background: transparent;
}

.btn-ghost[aria-pressed="true"] {
  color: var(--violet);
  border-color: rgba(192, 132, 252, 0.5);
  background: rgba(192, 132, 252, 0.12);
}

.btn-xs {
  min-height: 28px;
  padding: 0 9px;
  font-size: 0.68rem;
}

.btn-icon {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.68rem;
}

/* ── Grille principale ────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(350px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.panel {
  position: relative;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(15, 23, 35, 0.92), rgba(8, 13, 21, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    0 26px 70px -55px #000;
}

.camera-panel {
  grid-column: 1;
}

.drive-panel {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}

.arm-panel {
  grid-column: 1;
}

.log-panel {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-self: start;
}

.safety-panel {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.kicker {
  margin: 0 0 3px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.panel h2 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 750;
  letter-spacing: -0.015em;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 7px;
  color: var(--accent-2);
  background: rgba(56, 189, 248, 0.07);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

/* ── Caméra ───────────────────────────────────────────────────────────── */

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.live[data-state="live"] {
  color: var(--danger);
  border-color: rgba(255, 77, 109, 0.4);
  background: rgba(255, 77, 109, 0.08);
}

.live[data-state="live"] .live-dot {
  animation: pulse 1.4s ease-in-out infinite;
}

.live[data-state="demo"] {
  color: var(--violet);
  border-color: rgba(192, 132, 252, 0.4);
  background: rgba(192, 132, 252, 0.08);
}

.camera-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(148, 177, 204, 0.18);
  border-radius: 13px;
  background: #020406;
  aspect-ratio: 16 / 9;
  isolation: isolate;
}

.camera-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 240ms ease;
  background: #020406;
}

.camera-stage.is-live img {
  opacity: 1;
}

.camera-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.09), transparent 60%),
    repeating-linear-gradient(0deg, rgba(148, 177, 204, 0.035) 0 1px, transparent 1px 4px),
    #03070c;
  transition: opacity 240ms ease;
}

.camera-stage.is-live .camera-fallback {
  opacity: 0;
  pointer-events: none;
}

.fallback-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.fallback-sub {
  margin: 0;
  max-width: 42ch;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--faint);
}

.fallback-sub code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(148, 177, 204, 0.1);
  font-family: var(--mono);
  font-size: 0.92em;
}

.scan {
  position: relative;
  width: 54px;
  height: 54px;
  margin: 0 auto 8px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 50%;
}

.scan::before,
.scan::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: 50%;
}

.scan::after {
  inset: 22px;
  border-color: var(--accent);
}

.camera-stage:not(.is-live) .scan::before {
  animation: ping 2.4s ease-out infinite;
}

.hud {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 1px solid rgba(148, 177, 204, 0.16);
  border-radius: 5px;
  background: rgba(2, 6, 10, 0.66);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  backdrop-filter: blur(4px);
}

.hud-tl {
  top: 10px;
  left: 10px;
}

.hud-tr {
  top: 10px;
  right: 10px;
}

.hud-br {
  right: 10px;
  bottom: 10px;
}

.rec-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
}

.camera-stage.is-live .rec-dot {
  animation: pulse 1.4s ease-in-out infinite;
}

.reticle {
  position: absolute;
  inset: 18%;
  z-index: 1;
  opacity: 0.42;
  pointer-events: none;
}

.reticle span {
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: rgba(94, 234, 212, 0.7);
  border-style: solid;
}

.reticle span:nth-child(1) {
  top: 0;
  left: 0;
  border-width: 1px 0 0 1px;
}

.reticle span:nth-child(2) {
  top: 0;
  right: 0;
  border-width: 1px 1px 0 0;
}

.reticle span:nth-child(3) {
  bottom: 0;
  left: 0;
  border-width: 0 0 1px 1px;
}

.reticle span:nth-child(4) {
  right: 0;
  bottom: 0;
  border-width: 0 1px 1px 0;
}

.camera-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.66rem;
}

/* ── Conduite ─────────────────────────────────────────────────────────── */

.drive-grid {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(150px, 1.1fr);
  gap: 18px;
  align-items: center;
  flex: 1;
}

.joystick-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.joystick {
  position: relative;
  width: min(190px, 100%);
  aspect-ratio: 1;
  border: 1px solid rgba(94, 234, 212, 0.22);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(94, 234, 212, 0.09), transparent 58%),
    radial-gradient(circle at 50% 50%, #0b1420, #05090f 72%);
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.55),
    0 0 0 6px rgba(94, 234, 212, 0.03);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.joystick:active {
  cursor: grabbing;
}

.joystick.is-locked {
  cursor: not-allowed;
  filter: grayscale(0.6);
  opacity: 0.65;
}

.joystick-grid {
  position: absolute;
  inset: 12%;
  border: 1px dashed rgba(148, 177, 204, 0.16);
  border-radius: 50%;
}

.joystick-axis {
  position: absolute;
  background: rgba(148, 177, 204, 0.12);
}

.joystick-axis-x {
  top: 50%;
  left: 8%;
  right: 8%;
  height: 1px;
}

.joystick-axis-y {
  top: 8%;
  bottom: 8%;
  left: 50%;
  width: 1px;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(94, 234, 212, 0.55);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.2), transparent 45%),
    linear-gradient(150deg, rgba(94, 234, 212, 0.32), rgba(56, 189, 248, 0.14));
  box-shadow:
    0 0 24px rgba(94, 234, 212, 0.26),
    inset 0 0 16px rgba(2, 6, 12, 0.6);
  transform: translate(-50%, -50%);
  will-change: transform;
}

.joystick-knob span {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(231, 238, 247, 0.7);
  border-radius: 50%;
}

.drive-controls {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field label {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field output {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--accent);
}

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(94, 234, 212, 0.65), rgba(56, 189, 248, 0.25));
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(94, 234, 212, 0.65), rgba(56, 189, 248, 0.25));
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5.5px;
  border: 2px solid #06131a;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(94, 234, 212, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid #06131a;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(94, 234, 212, 0.5);
}

.tracks {
  display: grid;
  gap: 10px;
}

.track {
  display: grid;
  gap: 5px;
}

.track-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
}

.track-head b {
  color: var(--ink);
  font-size: 0.72rem;
}

.meter {
  position: relative;
  height: 7px;
  overflow: hidden;
  border: 1px solid rgba(148, 177, 204, 0.12);
  border-radius: 999px;
  background: rgba(3, 7, 12, 0.85);
}

.meter::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(231, 238, 247, 0.3);
}

.meter i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 60ms linear, left 60ms linear;
}

.hint {
  margin: 0;
  color: var(--faint);
  font-size: 0.7rem;
  line-height: 1.45;
}

.estop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin-top: 16px;
  border: 1px solid rgba(255, 77, 109, 0.5);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 77, 109, 0.16), rgba(255, 77, 109, 0.06)),
    rgba(20, 8, 13, 0.8);
  color: #ffb3c0;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.estop:hover {
  background:
    linear-gradient(180deg, rgba(255, 77, 109, 0.25), rgba(255, 77, 109, 0.1)),
    rgba(26, 9, 15, 0.9);
  box-shadow: 0 0 28px -10px rgba(255, 77, 109, 0.8);
}

.estop-icon {
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 2px;
}

.estop kbd {
  padding: 2px 6px;
  border: 1px solid rgba(255, 179, 192, 0.3);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(255, 179, 192, 0.75);
}

.estop.is-latched {
  color: #fff;
  background: linear-gradient(180deg, #ff3d61, #c81e42);
  border-color: #ff8aa0;
  box-shadow: 0 0 34px -6px rgba(255, 61, 97, 0.65);
  animation: danger-glow 1.6s ease-in-out infinite;
}

body.emergency .drive-panel {
  border-color: rgba(255, 77, 109, 0.45);
}

/* ── Bras ─────────────────────────────────────────────────────────────── */

.arm-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.95fr) minmax(220px, 1.05fr);
  gap: 20px;
  align-items: center;
}

.arm-viz {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.arm-viz svg {
  width: min(280px, 100%);
  height: auto;
  overflow: visible;
}

.viz-floor {
  fill: rgba(94, 234, 212, 0.05);
  stroke: rgba(94, 234, 212, 0.14);
  stroke-width: 1;
}

.viz-base {
  fill: url(#baseGradient);
  stroke: rgba(94, 234, 212, 0.24);
  stroke-width: 1;
}

.viz-base-core {
  fill: rgba(94, 234, 212, 0.08);
  stroke: rgba(94, 234, 212, 0.3);
  stroke-width: 1;
}

.viz-pointer {
  fill: var(--accent);
  opacity: 0.8;
}

.viz-link {
  fill: url(#armGradient);
  filter: drop-shadow(0 0 8px rgba(94, 234, 212, 0.28));
}

.viz-joint {
  fill: #0b1622;
  stroke: var(--accent);
  stroke-width: 2;
}

.viz-tool {
  fill: none;
  stroke: rgba(231, 238, 247, 0.7);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.arm-readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  gap: 6px;
}

.arm-readout div {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(6, 11, 18, 0.65);
  text-align: center;
}

.arm-readout span {
  font-size: 0.6rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.arm-readout b {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
}

.arm-controls {
  display: grid;
  gap: 13px;
}

.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.presets button {
  min-height: 32px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 15, 24, 0.7);
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.presets button:hover {
  border-color: rgba(94, 234, 212, 0.4);
  color: var(--accent);
  background: rgba(94, 234, 212, 0.07);
}

/* ── Journal ──────────────────────────────────────────────────────────── */

.log {
  display: grid;
  align-content: start;
  gap: 6px;
  max-height: 210px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
}

.log li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 8px;
  border-left: 2px solid rgba(94, 234, 212, 0.25);
  border-radius: 0 6px 6px 0;
  background: rgba(6, 11, 18, 0.55);
  font-family: var(--mono);
  font-size: 0.66rem;
  line-height: 1.45;
}

.log li time {
  color: var(--faint);
}

.log li span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.log li.is-warn {
  border-left-color: var(--amber);
}

.log li.is-error {
  border-left-color: var(--danger);
}

.log li.is-ok {
  border-left-color: var(--accent);
}

.safety-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.safety-list div {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(6, 11, 18, 0.55);
}

.safety-list dt {
  font-size: 0.6rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.safety-list dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--accent);
}

.safety-panel .hint {
  margin-top: 11px;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 4px 0;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.04em;
}

/* ── Mode démo ────────────────────────────────────────────────────────── */

body.demo .camera-fallback {
  background:
    radial-gradient(circle at 50% 50%, rgba(192, 132, 252, 0.16), transparent 62%),
    repeating-linear-gradient(0deg, rgba(192, 132, 252, 0.05) 0 1px, transparent 1px 4px),
    #07040c;
}

body.demo .scan {
  border-color: rgba(192, 132, 252, 0.45);
}

body.demo .scan::before,
body.demo .scan::after {
  border-color: rgba(192, 132, 252, 0.3);
}

body.demo .estop {
  opacity: 0.5;
  pointer-events: none;
}

/* ── Animations ───────────────────────────────────────────────────────── */

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}

@keyframes ping {
  0% {
    transform: scale(0.8);
    opacity: 0.9;
  }
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

@keyframes danger-glow {
  0%,
  100% {
    box-shadow: 0 0 26px -8px rgba(255, 61, 97, 0.6);
  }
  50% {
    box-shadow: 0 0 44px -2px rgba(255, 61, 97, 0.85);
  }
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .camera-panel,
  .drive-panel,
  .arm-panel,
  .log-panel,
  .safety-panel {
    grid-column: 1;
  }

  .camera-panel {
    order: 1;
  }

  .drive-panel {
    order: 2;
  }

  .arm-panel {
    order: 3;
  }

  .log-panel {
    order: 4;
  }

  .safety-panel {
    order: 5;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 10px 10px 22px;
  }

  .topbar {
    position: static;
    padding: 10px 12px;
  }

  .status-cluster {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .metrics {
    gap: 12px;
  }

  .metric:nth-child(2) {
    display: none;
  }

  .panel {
    padding: 14px;
  }

  .drive-grid,
  .arm-grid {
    grid-template-columns: 1fr;
  }

  .drive-grid {
    justify-items: stretch;
  }

  .joystick {
    width: min(200px, 70vw);
  }

  .joystick-wrap {
    justify-items: center;
  }

  .arm-viz svg {
    width: min(240px, 78vw);
  }

  .presets {
    grid-template-columns: repeat(2, 1fr);
  }

  .safety-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .camera-foot span {
    max-width: 62%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .estop kbd {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
