:root {
  color-scheme: dark;
  --bg: #0f1419;
  --panel: #161c24;
  --border: #2a3442;
  --text: #e7edf5;
  --muted: #8b99ad;
  --accent: #3b82f6;
  --danger: #ef4444;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body.boot-loading {
  overflow: hidden;
}

.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding: 2rem 1.5rem;
  text-align: center;
  background: rgba(10, 14, 20, 0.94);
  backdrop-filter: blur(8px);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.boot-overlay.boot-overlay--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: boot-spin 0.85s linear infinite;
}

@keyframes boot-spin {
  to {
    transform: rotate(360deg);
  }
}

.boot-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.boot-message {
  margin: 0;
  max-width: 36rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--muted);
}

a {
  color: #93c5fd;
}

.header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.localhost-dev-badge {
  color: var(--danger);
  font-weight: 500;
  font-size: 0.72em;
  margin-left: 0.45rem;
  white-space: nowrap;
  vertical-align: middle;
}

.btn-logout {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #1c2430;
  color: var(--muted);
  cursor: pointer;
}

.btn-logout:hover {
  color: var(--text);
  border-color: #3d4d62;
}

.sub {
  margin: 0;
  color: var(--muted);
  max-width: 70ch;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.stream-group-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.stream-group-field-heading {
  font: inherit;
  color: inherit;
  cursor: default;
}

.stream-group-input-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.stream-group-input-row input {
  flex: 1 1 0;
  min-width: 0;
}

.btn-load-sg {
  flex: 0 0 auto;
  white-space: nowrap;
}

.app-list-error {
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.85rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.cold-start-hint {
  margin: -0.25rem 0 0.55rem;
  font-size: 0.78rem;
  line-height: 1.3;
  max-width: 40rem;
}

input,
select {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0b0f14;
  color: var(--text);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

button {
  padding: 0.55rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #1c2430;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: #2563eb;
}

button.danger {
  background: #3a1b1b;
  border-color: #7f1d1d;
  color: #fecaca;
}

.stream {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  overflow: hidden;
}

.stream-video-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}

video {
  width: 100%;
  max-height: min(80vh, 900px);
  background: #000;
  border-radius: 10px;
}

audio {
  display: none;
}

.stream-stats-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.65rem;
  margin: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #c8d4e6;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
}

.stream-stat {
  white-space: nowrap;
}

.stream-stat-sep {
  color: var(--muted);
  user-select: none;
}

.status {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  word-break: break-all;
}

.muted {
  color: var(--muted);
}

.stream-debug {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.stream-debug-title {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stream-debug-line {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
}

.stream-debug-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.stream-debug-toggle input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.debug-log {
  margin: 0;
  max-height: 11rem;
  overflow: auto;
  padding: 0.5rem 0.55rem;
  font-size: 0.72rem;
  line-height: 1.45;
  background: #0b0f14;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #c8d4e6;
  white-space: pre-wrap;
  word-break: break-word;
}

.session-uptime {
  margin: 0;
  padding: 0.5rem 0.75rem 0.65rem;
  font-size: 0.8rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
}

body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-shell {
  width: 100%;
  max-width: 22rem;
}

.login-shell h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.login-error {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #fecaca;
}

.login-version {
  margin: 1.25rem 0 0;
  font-size: 0.75rem;
  text-align: center;
}
