.dashboard-camera-pip {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  box-sizing: border-box;
  width: min(430px, calc(100vw - 28px));
  min-width: min(200px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  border: 1px solid var(--kd-border-strong);
  border-radius: var(--kd-radius-lg);
  background: var(--kd-surface);
  box-shadow: 0 18px 48px rgb(0 0 0 / 24%);
}

.dashboard-camera-pip[hidden] {
  display: none !important;
}

.dashboard-camera-pip[data-collapsed="true"] {
  overflow: hidden;
}

.dashboard-camera-pip[data-collapsed="true"] .dashboard-camera-card-host {
  display: none;
}

.dashboard-camera-pip[data-collapsed="true"] .dashboard-camera-pip-header {
  border-bottom: 0;
}

.dashboard-camera-pip-header {
  position: sticky;
  z-index: 8;
  top: 0;
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 8px;
  border-bottom: 1px solid var(--kd-border);
  background: color-mix(in srgb, var(--kd-surface-2) 94%, transparent);
  backdrop-filter: blur(10px);
}

.dashboard-camera-source-picker {
  position: relative;
  min-width: 0;
  flex: 1 1 auto;
}

.dashboard-camera-source-picker::after {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--kd-muted);
  border-bottom: 1.5px solid var(--kd-muted);
  content: "";
  pointer-events: none;
  transform: translateY(-70%) rotate(45deg);
}

.dashboard-camera-source {
  width: 100%;
  min-width: 0;
  height: 28px;
  min-height: 28px;
  padding: 0 24px 0 8px;
  border: 0;
  border-radius: var(--kd-radius-md);
  appearance: none;
  background: transparent;
  color: var(--kd-ink);
  font: inherit;
  font-size: var(--kd-text-sm);
  font-weight: var(--kd-weight-medium);
  text-overflow: ellipsis;
  cursor: pointer;
}

.dashboard-camera-source:hover:not(:disabled),
.dashboard-camera-source:focus-visible {
  background: var(--kd-row-hover);
  outline: none;
}

.dashboard-camera-source:disabled {
  color: var(--kd-muted);
  cursor: default;
}

.dashboard-camera-open-page,
.dashboard-camera-close {
  display: grid;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--kd-muted);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.dashboard-camera-open-page {
  font-size: 15px;
}

.dashboard-camera-close {
  font-size: 20px;
  line-height: 1;
}

.dashboard-camera-open-page:hover,
.dashboard-camera-open-page:focus-visible,
.dashboard-camera-close:hover,
.dashboard-camera-close:focus-visible {
  background: var(--kd-row-hover);
  color: var(--kd-ink);
  outline: none;
}

.dashboard-camera-card-host {
  min-height: 0;
}

.dashboard-camera-resize-handle {
  display: grid;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--kd-muted);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}

.dashboard-camera-resize-handle:hover,
.dashboard-camera-resize-handle:focus-visible,
.dashboard-camera-pip[data-resizing="true"] .dashboard-camera-resize-handle {
  background: var(--kd-row-hover);
  color: var(--kd-ink);
  outline: none;
}

.dashboard-camera-card-host > .camera-tile {
  border: 0;
  border-radius: 0;
}

.dashboard-camera-card-host > .camera-tile .camera-tile-header {
  display: none;
}

.dashboard-camera-card-host .camera-stage {
  /* A short viewport can require a shorter, letterboxed camera stage. */
  max-height: var(--dashboard-camera-stage-max-height, none);
}

.dashboard-camera-card-host .camera-slices {
  /* Keep both diagnostic plots side by side even in a narrow browser. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-camera-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 18px;
  color: var(--kd-muted);
  background: #050505;
  font-size: var(--kd-text-sm);
  text-align: center;
}

@media (max-width: 560px) {
  .dashboard-camera-pip {
    right: 8px;
    bottom: 8px;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .dashboard-camera-pip[data-collapsed="true"] {
    display: none;
  }

  .dashboard-camera-pip-header {
    min-height: 34px;
    padding: 4px 5px 4px 7px;
  }

  .dashboard-camera-source {
    height: 26px;
    min-height: 26px;
    font-size: 10px;
  }

  .dashboard-camera-resize-handle,
  .dashboard-camera-open-page,
  .dashboard-camera-close {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
  }
}
