:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #17202a;
  --muted: #5d6975;
  --line: #c9d1d9;
  --accent: #197278;
  --button: #243447;
  --button-hover: #1d5f73;
  --danger: #c2413d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

button {
  border: 1px solid transparent;
  border-radius: 6px;
  color: #fff;
  background: var(--button);
  font: inherit;
  font-weight: 650;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover:not(:disabled),
button:focus-visible:not(:disabled) {
  background: var(--button-hover);
  outline: 2px solid #84b8c8;
  outline-offset: 1px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  min-height: 100vh;
}

.workspace {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.toolbar-groups {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.recording-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.recording-path {
  max-width: min(48vw, 420px);
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-band {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  min-height: 0;
}

.board-stage {
  min-height: 0;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#boardSvg {
  width: min(100%, 1100px);
  height: min(78vh, 760px);
  display: block;
  background: #fdfefe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.board-outline line,
.board-outline path,
.board-outline circle {
  fill: none;
  stroke: #22313f;
  stroke-width: 0.7;
  vector-effect: non-scaling-stroke;
}

.sensor-marker {
  cursor: pointer;
}

.sensor-marker text {
  font-size: 3.1px;
  font-weight: 700;
  fill: #233140;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 0.8px;
  stroke-linejoin: round;
  pointer-events: none;
}

.sensor-marker circle {
  vector-effect: non-scaling-stroke;
}

.sensor-marker.is-selected circle {
  stroke-width: 1.2;
  stroke: #111827;
}

.sensor-marker:focus-visible circle {
  stroke: #0f766e;
  stroke-width: 1.4;
}

.side-panel {
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.sensor-detail,
.diagnostics,
.recording-panel {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.side-panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(95px, 0.42fr) minmax(0, 1fr);
  gap: 8px 12px;
  font-size: 13px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 620;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

  .toolbar-groups,
  .recording-actions {
    align-items: stretch;
    width: 100%;
  }

  .recording-path {
    max-width: 100%;
  }

  .viewer-band {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }

  #boardSvg {
    height: 58vh;
  }
}

@media (max-width: 520px) {
  .topbar,
  .board-stage,
  .sensor-detail,
  .diagnostics,
  .recording-panel {
    padding: 12px;
  }

  .actions button {
    flex: 1 1 145px;
  }

  .recording-actions button {
    flex: 1 1 150px;
  }

  dl {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
