:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111317;
  color: #eceff3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #111317;
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 170px;
  min-height: 100vh;
}

.controls {
  border-right: 1px solid #2b3037;
  grid-row: 1 / span 2;
  padding: 18px;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #aeb6c2;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid #3a414c;
  border-radius: 6px;
  background: #191d23;
  color: #f7f9fb;
  font: inherit;
  padding: 8px 10px;
}

input {
  min-height: 38px;
}

textarea {
  min-height: 126px;
  resize: vertical;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

input:focus,
textarea:focus {
  border-color: #6aa9ff;
  outline: 2px solid rgba(106, 169, 255, 0.25);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

button {
  min-height: 38px;
  border: 1px solid #48515e;
  border-radius: 6px;
  background: #e8edf5;
  color: #15191f;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

button[type="button"] {
  background: #20262e;
  color: #e8edf5;
}

.stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  background: #050607;
}

.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 16px;
  align-items: start;
}

.stream-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid #2b3037;
  border-radius: 6px;
  background: #11151a;
  padding: 12px;
}

.stream-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

h2 {
  margin: 0;
  overflow: hidden;
  color: #f5f7fb;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-status {
  flex: 0 0 auto;
  color: #8fe388;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.stream-status[data-state="error"],
.stream-status[data-state="failed"],
.stream-status[data-state="disconnected"] {
  color: #ff9d9d;
}

.stream-track {
  overflow: hidden;
  color: #9fa9b7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-preview {
  justify-self: center;
  width: min(100%, 420px);
  aspect-ratio: 9 / 16;
  background: #030405;
  border: 1px solid #2b3037;
  border-radius: 6px;
  overflow: hidden;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #030405;
}

.telemetry {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 28px;
  color: #cbd3df;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
}

.stream-log {
  min-height: 86px;
  max-height: 120px;
  overflow: auto;
  border-top: 1px solid #242a32;
  margin: 0;
  padding: 9px 0 0;
  color: #aeb8c7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.log-panel {
  border-top: 1px solid #2b3037;
  min-height: 0;
  overflow: auto;
}

#log {
  margin: 0;
  padding: 14px;
  color: #bcc5d2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(320px, 1fr) 180px;
  }

  .controls {
    border-right: 0;
    border-bottom: 1px solid #2b3037;
    grid-row: auto;
  }

  .stage {
    padding: 12px;
  }

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

  .stream-preview {
    width: min(100%, 360px);
  }
}
