:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #f5f7fa;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid #c9d3df;
  background: #ffffff;
  color: #17202a;
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
}

button:hover {
  background: #edf3f8;
}

button.dirtyAction {
  border-color: #1d70d8;
  background: #1d70d8;
  color: #ffffff;
}

button.dirtyAction:hover {
  background: #155fb8;
}

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

button:disabled:hover {
  background: #ffffff;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.panel {
  background: #ffffff;
  border: 1px solid #dce3ea;
  border-radius: 8px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 360px) auto;
  gap: 16px;
  align-items: end;
  padding: 18px;
  margin-bottom: 16px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
  margin: 18px 0 8px;
}

.tokenBox {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #c9d3df;
  border-radius: 6px;
  padding: 9px 10px;
  background: #ffffff;
}

textarea {
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.deviceList {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.deviceItem {
  text-align: left;
  display: grid;
  gap: 4px;
}

.deviceItem.active {
  border-color: #2374ab;
  background: #eaf4fb;
}

.deviceMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: #314255;
}

.deviceState {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.deviceState.online {
  background: #dff7e8;
  color: #146c38;
}

.deviceState.offline {
  background: #f2f4f7;
  color: #667085;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eceff3;
  color: #4f5965;
  font-size: 13px;
}

.badge.online {
  background: #dff7e8;
  color: #146c38;
}

.badge.offline {
  background: #f2f4f7;
  color: #667085;
}

.connectionSummary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  color: #536170;
  font-size: 13px;
}

.connectionSummary span {
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.statusCards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.statusCard {
  display: grid;
  gap: 6px;
  min-height: 82px;
  border: 1px solid #dce3ea;
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.statusCard span {
  color: #5b6774;
  font-size: 13px;
}

.statusCard strong {
  overflow-wrap: anywhere;
  font-size: 16px;
}

.statusCard small {
  color: #5b6774;
  font-size: 13px;
}

.resolutionPanel {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 14px;
}

.cameraControlsDetails {
  border-top: 1px solid #dce3ea;
  padding-top: 14px;
  margin-top: 14px;
}

.cameraControlsDetails > summary {
  font-size: 18px;
  font-weight: 700;
  color: #17202a;
}

.cameraControlsHeader {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-top: 16px;
}

.cameraControlsHeader p {
  margin-top: 5px;
  color: #5b6774;
  font-size: 13px;
}

.compactActions {
  flex: 0 0 auto;
  margin: 0;
}

.cameraControlsGroups {
  display: grid;
  gap: 18px;
}

.cameraControlGroup h3 {
  margin: 0 0 9px;
}

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

.cameraControl {
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #dce3ea;
  border-radius: 6px;
  background: #f8fafc;
}

.cameraControl.unsupported {
  opacity: 0.58;
}

.cameraControlHeading,
.cameraControlRange,
.cameraControlToggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cameraControlHeading {
  justify-content: space-between;
}

.cameraControlRange input {
  flex: 1 1 auto;
  padding: 0;
}

.cameraControlRange output {
  flex: 0 0 76px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.cameraControlToggle input {
  width: auto;
}

.cameraControlAutoToggle {
  width: fit-content;
  color: #334155;
  font-weight: 600;
}

.cameraControlLimits,
.cameraControlHint,
.unsupportedText {
  color: #5b6774;
  font-size: 12px;
}

.cameraControlHint {
  color: #b45309;
}

.smallAction {
  padding: 5px 8px;
  font-size: 12px;
}

.focusStatusSection {
  border-top: 1px solid #dce3ea;
  padding-top: 16px;
  margin-top: 16px;
}

.focusDetail {
  margin-top: 9px;
  color: #5b6774;
  overflow-wrap: anywhere;
}

.badge.focusScanning {
  background: #fff4cc;
  color: #8a5a00;
}

.badge.focusFocused {
  background: #dff7e8;
  color: #146c38;
  animation: focusFade 3s ease 1.5s forwards;
}

.badge.focusError {
  background: #fee4e2;
  color: #b42318;
}

.badge.focusCancelled {
  animation: focusFade 1s ease forwards;
}

@keyframes focusFade {
  to {
    opacity: 0.35;
  }
}

.streamSection {
  border-top: 1px solid #dce3ea;
  border-bottom: 1px solid #dce3ea;
  padding: 16px 0;
  margin: 16px 0;
}

.networkDiagnosticsDetails {
  border-top: 1px solid #dce3ea;
  border-bottom: 1px solid #dce3ea;
  padding: 16px 0;
  margin: 16px 0;
}

.networkDiagnosticsDetails > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  list-style-position: inside;
}

.networkDiagnosticsDetails > summary::marker {
  font-size: 14px;
}

.networkDiagnosticsSample {
  margin: 10px 0 0;
  color: #5b6774;
  font-size: 13px;
}

.networkDiagnosticsGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
  margin-top: 12px;
}

.networkDiagnosticGroup {
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid #e6ebf0;
}

.networkDiagnosticGroup h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.networkMetricList {
  display: grid;
  gap: 7px;
  margin: 0;
}

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

.networkMetric dt,
.networkMetric dd {
  margin: 0;
  min-width: 0;
}

.networkMetric dt {
  color: #5b6774;
  font-size: 13px;
}

.networkMetric dd {
  text-align: right;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.networkMetric.warning dd {
  color: #b54708;
  font-weight: 700;
}

.badge.networkFresh {
  background: #dff7e8;
  color: #146c38;
}

.badge.networkStale {
  background: #fff4cc;
  color: #8a5a00;
}

.networkTrendsDetails {
  margin-top: 8px;
}

.networkTrendsDetails > summary {
  color: #344054;
  cursor: pointer;
  font-size: 14px;
}

.networkDiagnosticsCharts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.networkChart {
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid #dce3ea;
  border-radius: 8px;
  background: #f8fafc;
}

.networkChart figcaption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.networkChartValue {
  color: #475467;
  font-variant-numeric: tabular-nums;
}

.networkChart svg {
  display: block;
  width: 100%;
  height: 58px;
  overflow: visible;
}

.networkChartEmpty {
  display: grid;
  place-items: center;
  min-height: 58px;
  color: #667085;
  font-size: 13px;
}

.snapshotSection {
  border-top: 1px solid #dce3ea;
  padding-top: 16px;
  margin-top: 16px;
}

.snapshotEncodingField {
  display: grid;
  gap: 6px;
  width: min(100%, 420px);
  margin-top: 14px;
}

.snapshotEncodingField > span,
.settingDescription {
  color: #5b6774;
  font-size: 13px;
}

.settingDescription {
  min-height: 20px;
  margin: 8px 0 0;
}

.snapshotForm {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.snapshotForm label,
.snapshotActions label {
  min-width: 0;
}

.snapshotForm span,
.snapshotActions span {
  color: #5b6774;
  font-size: 13px;
}

.snapshotForm label {
  display: grid;
  gap: 6px;
}

.snapshotActions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.advancedDetails {
  margin-top: 10px;
}

.advancedForm {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.streamMeta {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 10px;
  margin: 14px 0;
}

.streamMeta div {
  display: grid;
  gap: 6px;
  min-height: 64px;
  border: 1px solid #dce3ea;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.streamMeta span,
.streamForm span {
  color: #5b6774;
  font-size: 13px;
}

.streamMeta strong,
.streamMeta a {
  overflow-wrap: anywhere;
}

.streamForm {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.streamForm label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.streamForm label:nth-child(1),
.streamForm label:nth-child(2),
.streamForm label:nth-child(3) {
  grid-column: span 4;
}

.streamForm label:nth-child(4),
.streamForm label:nth-child(5),
.streamForm label:nth-child(6),
.streamForm label:nth-child(7),
.streamForm label:nth-child(8) {
  grid-column: span 2;
}

.sharedStreamForm,
.rtmpForm,
.whipForm {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.rtmpForm label,
.whipForm label {
  grid-column: span 3 !important;
}

.sharedStreamForm label {
  grid-column: span 4 !important;
}

.rtmpForm label:nth-child(1),
.rtmpForm label:nth-child(2),
.whipForm label:first-child {
  grid-column: span 6 !important;
}

.commandFeedback {
  min-height: 20px;
  margin: 12px 0;
  color: #536170;
  font-size: 14px;
}

.commandFeedback.pending {
  color: #1d70d8;
}

.commandFeedback.success {
  color: #146c38;
}

.commandFeedback.error {
  color: #b42318;
}

select {
  width: 100%;
  min-width: 0;
  border: 1px solid #c9d3df;
  border-radius: 6px;
  padding: 9px 10px;
  background: #ffffff;
  font: inherit;
}

.checkLabel {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  min-height: 40px;
  gap: 8px !important;
}

.checkLabel input {
  width: auto;
}

.warningText {
  min-height: 20px;
  margin-top: 10px;
  color: #b45309;
  font-size: 14px;
}

details {
  margin-top: 4px;
}

summary {
  cursor: pointer;
  color: #3f4a56;
  font-size: 14px;
}

.customCommand {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  gap: 10px;
  align-items: start;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.snapshotsSection {
  margin-top: 18px;
}

.playersSection {
  margin-top: 18px;
  border-top: 1px solid #dce3ea;
  padding-top: 18px;
}

.playerList {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.playerItem {
  display: grid;
  gap: 8px;
  border: 1px solid #dce3ea;
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.playerTitle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.playerMeta,
.emptyText {
  color: #5b6774;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.playerItem a {
  overflow-wrap: anywhere;
}

.debugDetails {
  margin-top: 18px;
  border-top: 1px solid #dce3ea;
  padding-top: 12px;
}

.debugGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 10px;
}

pre {
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin: 0;
  padding: 12px;
  border: 1px solid #dce3ea;
  border-radius: 8px;
  background: #111820;
  color: #e8eef5;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.snapshotList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  align-items: start;
}

.snapshotList a {
  display: block;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #dce3ea;
  border-radius: 8px;
  background: #eef2f6;
}

.snapshotList img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 160ms ease;
}

.snapshotList a:hover img {
  transform: scale(1.025);
}

.snapshotList a:focus-visible {
  outline: 2px solid #1677c8;
  outline-offset: 2px;
}

.eventLog {
  min-height: 160px;
  overflow-x: hidden;
}

@media (max-width: 860px) {
  .topbar,
  .layout,
  .grid,
  .statusCards,
  .resolutionPanel,
  .streamMeta,
  .streamForm,
  .snapshotForm,
  .advancedForm,
  .cameraControlGrid,
  .networkDiagnosticsGrid,
  .networkDiagnosticsCharts,
  .customCommand {
    grid-template-columns: 1fr;
  }

  .streamForm label,
  .sharedStreamForm label,
  .rtmpForm label,
  .whipForm label,
  .rtmpForm label:nth-child(1),
  .rtmpForm label:nth-child(2),
  .whipForm label:first-child {
    grid-column: auto;
  }

  .cameraControlsHeader {
    display: grid;
  }

  .compactActions {
    justify-content: start;
  }
}

@media (max-width: 480px) {
  .snapshotList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
