:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f2430;
  --line: #303642;
  --text: #f3f5f8;
  --muted: #9aa4b2;
  --accent: #20b486;
  --warn: #ffbf3f;
  --danger: #ff5a5f;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #12151b;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

p {
  margin: 0;
}

#source {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 14px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(255, 191, 63, 0.12);
}

.dot.ok {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(32, 180, 134, 0.14);
}

.dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 90, 95, 0.14);
}

.reconnect-btn {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.reconnect-btn:hover {
  border-color: rgba(32, 180, 134, 0.7);
}

.reconnect-btn:disabled {
  cursor: wait;
  opacity: 0.64;
}

.layout {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  overflow: hidden;
}

.video-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  background: #080a0d;
}

#stream {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

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

.metric-group {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.metric-group:first-child {
  padding-top: 0;
}

.metric-group h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

dl div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
}

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 0;
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.error {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 90, 95, 0.45);
  background: rgba(255, 90, 95, 0.1);
  color: #ffd7d9;
  font-size: 13px;
  line-height: 1.4;
}

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

  .status {
    justify-content: flex-start;
    min-width: 0;
  }

  .layout {
    height: auto;
    min-height: calc(100vh - 104px);
    grid-template-columns: 1fr;
  }

  .video-pane {
    height: 56vh;
  }

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