* {
  box-sizing: border-box;
}

.detection-body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.2), transparent 24%),
    linear-gradient(180deg, #020617 0%, #02030a 100%);
  color: #e2e8f0;
}

.detection-shell {
  width: 100vw;
  height: 100vh;
}

.ad-stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

.ad-player {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.hud {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 20;
  width: min(620px, calc(100vw - 44px));
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

.toolbar-brand {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.brand-mark {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  margin-top: 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.7);
}

.toolbar h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.toolbar h1 + p {
  margin: 0;
  color: #94a3b8;
  font-size: 13px;
}

.toolbar-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-nav a {
  padding: 9px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  font-weight: 600;
}

.toolbar-nav a.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.4);
  color: #eef2ff;
}

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
}

#cameraSelect {
  max-width: min(240px, 42vw);
}

#cameraRefreshBtn {
  padding-inline: 10px;
  font-size: 12px;
}

button,
select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: rgba(15, 23, 42, 0.95);
  color: #e2e8f0;
}

input[type="file"] {
  max-width: 200px;
  color: #cbd5e1;
}

button:disabled {
  opacity: 0.6;
}

.video-wrap {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  width: min(520px, 42vw);
  max-width: calc(100vw - 36px);
  aspect-ratio: 16 / 9;
  background: #020617cc;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.status {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.76);
  color: #bfdbfe;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.status-head,
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.status-head strong,
.panel-head h2 {
  margin: 0;
}

.status-head a,
.panel-head a {
  color: #c4b5fd;
  font-size: 12px;
  text-decoration: none;
}

#statusText {
  margin: 0;
  line-height: 1.5;
}

.ad-panel {
  margin-top: 10px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.panel-head p {
  margin: 4px 0 0;
  color: #94a3b8;
  font-size: 12px;
}

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

.ad-card {
  border: 1px solid rgba(71, 85, 105, 0.8);
  border-radius: 14px;
  padding: 12px;
  background: rgba(11, 18, 32, 0.92);
  min-width: 0;
  overflow: hidden;
}

.label {
  margin: 0 0 6px;
  color: #94a3b8;
  font-size: 13px;
}

.ad-title {
  margin: 0;
  color: #e2e8f0;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ad-url {
  margin: 6px 0 0;
  color: #a5b4fc;
  font-weight: 500;
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
}

#profileText,
#queueText {
  margin: 0;
  color: #e2e8f0;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#queueText {
  font-weight: 500;
  color: #cbd5e1;
}

@media (max-width: 1100px) {
  .video-wrap {
    width: min(460px, calc(100vw - 36px));
  }
}

@media (max-width: 840px) {
  .detection-shell,
  .ad-stage {
    height: auto;
    min-height: 100vh;
  }

  .hud,
  .video-wrap {
    position: static;
    width: auto;
    max-width: none;
  }

  .hud {
    padding: 18px;
  }

  .video-wrap {
    margin: 0 18px 18px;
  }
}

@media (max-width: 640px) {
  .controls {
    align-items: stretch;
  }

  .controls > * {
    width: 100%;
  }

  .ad-grid {
    grid-template-columns: 1fr;
  }
}
