:root {
  --bg: #0e1116;
  --panel: #171c24;
  --panel-2: #1f2632;
  --border: #2a3340;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; letter-spacing: 0.3px; }

.conn { display: flex; align-items: center; gap: 10px; }

input, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  outline: none;
}

input {
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 10px;
}

button {
  background: var(--accent);
  color: white;
  padding: 8px 14px;
  border: none;
  cursor: pointer;
  transition: filter 0.15s ease;
}
button:hover:not(:disabled) { filter: brightness(1.1); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--muted); padding: 2px 8px; }
button.danger { background: var(--red); }

.status {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
}
.status.offline { background: #3a2020; color: #ffb4b4; }
.status.online { background: #16351f; color: #9ff0b3; }

.layout { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-title {
  padding: 14px 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.badge {
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
}
.sidebar-title .ghost { margin-left: auto; font-size: 16px; }

.client-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }

.client-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.client-item:hover { background: var(--panel-2); }
.client-item.active { background: #1c2a42; outline: 1px solid var(--accent); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }

.client-name { font-weight: 500; }
.client-id { font-size: 12px; color: var(--muted); }

.content { flex: 1; display: flex; flex-direction: column; padding: 16px; gap: 16px; min-width: 0; }

.video-wrap {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  flex: 1;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}

#video { width: 100%; height: 100%; object-fit: contain; background: #000; flex: 1; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}
.overlay.hidden { display: none; }

.video-meta {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
}
.video-meta #sessionLabel { color: var(--muted); font-size: 13px; }
.video-meta .danger { margin-left: auto; }

.pill {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.pill.ok { color: #9ff0b3; border-color: #1f5130; }
.pill.warn { color: #ffd58a; border-color: #6b4e17; }
.pill.err { color: #ffb4b4; border-color: #6b2222; }

.serial {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  height: 240px;
}
.serial-title {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.serial-output {
  flex: 1;
  margin: 0;
  padding: 12px 14px;
  overflow-y: auto;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: #b8f0c8;
  white-space: pre-wrap;
  word-break: break-all;
}
.serial-input {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  align-items: center;
}
.serial-input input[type="text"] { flex: 1; }
.crlf { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
