:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #171b1f;
  --panel-strong: #20262b;
  --text: #f5f7f8;
  --muted: #aab3bd;
  --line: #303840;
  --awake: #49c78e;
  --warning: #ffd166;
  --danger: #ef476f;
  --blue: #4ea8de;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 10%, rgba(78, 168, 222, 0.16), transparent 28rem),
    linear-gradient(135deg, #101214 0%, #182126 48%, #121516 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  border-radius: 8px;
  color: #07100c;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 48px;
  padding: 0 18px;
}

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

.app-shell {
  min-height: 100vh;
  padding: clamp(16px, 2vw, 28px);
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  min-height: calc(100vh - clamp(32px, 4vw, 56px));
}

.video-stage {
  background: #050607;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  min-height: 360px;
  overflow: hidden;
  position: relative;
}

.video-stage::before {
  border: 8px solid var(--awake);
  border-radius: 8px;
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  transition: border-color 160ms ease;
  z-index: 4;
}

.video-stage.warning::before {
  border-color: var(--warning);
}

.video-stage.danger::before {
  border-color: var(--danger);
}

.video-stage.danger::after {
  animation: flash 700ms ease-in-out infinite alternate;
  background: rgba(239, 71, 111, 0.18);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 3;
}

video,
canvas {
  height: 100%;
  inset: 0;
  object-fit: cover;
  position: absolute;
  transform: scaleX(-1);
  width: 100%;
}

video {
  opacity: 0.96;
}

canvas {
  z-index: 2;
}

.stage-status {
  align-items: center;
  background: rgba(5, 6, 7, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
  display: flex;
  font-size: clamp(28px, 4vw, 56px);
  font-weight: 900;
  inset: 50% auto auto 50%;
  justify-content: center;
  line-height: 1;
  min-width: min(520px, 78vw);
  padding: 24px;
  position: absolute;
  text-align: center;
  transform: translate(-50%, -50%);
  z-index: 5;
}

.stage-status.hidden {
  display: none;
}

.control-panel {
  align-content: start;
  background: rgba(23, 27, 31, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  padding: 22px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(30px, 4vw, 44px);
  letter-spacing: 0;
  line-height: 0.98;
  margin: 0;
}

.status-card {
  align-items: center;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: auto 1fr;
  padding: 15px;
}

.status-dot {
  background: var(--awake);
  border-radius: 999px;
  box-shadow: 0 0 0 7px rgba(73, 199, 142, 0.14);
  display: block;
  height: 14px;
  width: 14px;
}

.status-card.warning .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 7px rgba(255, 209, 102, 0.14);
}

.status-card.danger .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 7px rgba(239, 71, 111, 0.14);
}

.status-label,
.status-detail {
  margin: 0;
}

.status-label {
  font-size: 20px;
  font-weight: 900;
}

.status-detail {
  color: var(--muted);
  line-height: 1.35;
  margin-top: 3px;
}

.metrics-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metrics-grid div {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 82px;
  padding: 13px;
}

.metrics-grid span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.metrics-grid strong {
  display: block;
  font-size: 27px;
  letter-spacing: 0;
  margin-top: 8px;
}

.signal-list {
  display: grid;
  gap: 8px;
}

.signal {
  background: rgba(73, 199, 142, 0.1);
  border: 1px solid rgba(73, 199, 142, 0.22);
  border-radius: 8px;
  color: #d8f8e9;
  font-weight: 800;
  padding: 12px 14px;
}

.signal.active {
  background: rgba(255, 209, 102, 0.12);
  border-color: rgba(255, 209, 102, 0.34);
  color: #fff2c1;
}

.signal.danger {
  background: rgba(239, 71, 111, 0.14);
  border-color: rgba(239, 71, 111, 0.42);
  color: #ffe2e9;
}

.button-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

#startButton {
  background: var(--awake);
}

#stopButton {
  background: #e7ecef;
}

.privacy-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

@keyframes flash {
  from {
    opacity: 0.35;
  }

  to {
    opacity: 0.85;
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .video-stage {
    aspect-ratio: 4 / 3;
    min-height: 0;
  }
}

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

  .control-panel {
    padding: 16px;
  }

  .metrics-grid,
  .button-row {
    grid-template-columns: 1fr;
  }
}
