*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --page: #0c0f14;
  --panel: #151a22;
  --panel-2: #1c232d;
  --line: #2d3745;
  --line-strong: #3b4858;
  --text: #eef3f8;
  --muted: #98a6b5;
  --soft: #c7d2df;
  --blue: #4db6ff;
  --green: #43d17a;
  --red: #ff5e66;
  --amber: #f7b955;
  --radius: 8px;
  color-scheme: dark;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--page);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app {
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(320px, 1fr) auto auto;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  font-size: 14px;
  color: var(--soft);
}

.connection {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 94, 102, 0.14);
  flex: 0 0 auto;
}

.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(67, 209, 122, 0.14);
}

.status-text {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.primary-button,
.segment {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

.primary-button {
  min-width: 104px;
  padding: 0 16px;
  background: var(--blue);
  border-color: var(--blue);
  color: #051018;
  font-weight: 800;
}

.primary-button.connected {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.control-strip {
  display: grid;
  grid-template-columns: auto repeat(3, minmax(160px, 1fr));
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #10151c;
}

.segment {
  min-width: 76px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.segment.active {
  color: #051018;
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 800;
}

.range-control {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.range-control span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.range-control strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  min-width: 120px;
  height: 4px;
  margin: 0;
  accent-color: var(--blue);
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.viewer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  min-height: 0;
}

.viewer-header,
.detections-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.viewer-header span,
.detections-header span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.media-box {
  position: relative;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #05070a;
}

video,
canvas {
  display: block;
  width: 100%;
  height: 100%;
}

video {
  object-fit: contain;
}

canvas {
  object-fit: contain;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 7, 10, 0.72);
  color: var(--muted);
  text-align: center;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.overlay.hidden {
  opacity: 0;
}

.telemetry {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.metric {
  min-width: 0;
  padding: 11px 10px;
  background: var(--panel);
}

.metric span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detections {
  display: grid;
  gap: 8px;
  min-height: 76px;
}

.detection-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.detection-list:empty::before {
  content: "No objects detected";
  color: var(--muted);
  font-size: 13px;
}

.det-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  max-width: 100%;
  padding: 5px 10px;
  border: 1px solid rgba(77, 182, 255, 0.34);
  border-radius: 6px;
  background: rgba(77, 182, 255, 0.12);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.det-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.det-chip strong {
  color: var(--blue);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 980px) {
  .app {
    grid-template-rows: auto auto auto auto auto;
    padding: 12px;
  }

  .topbar,
  .connection {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .connection {
    width: 100%;
  }

  .primary-button {
    margin-left: auto;
  }

  .control-strip,
  .stage,
  .telemetry {
    grid-template-columns: 1fr;
  }

  .media-box {
    aspect-ratio: 16 / 9;
    min-height: 220px;
  }
}

