: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: 0 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 1.25rem;
}

.app-tabs {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 0;
}

.app-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  max-width: 22rem;
  padding: 1.15rem 1.5rem;
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.app-tab:hover {
  color: var(--text);
  background: rgba(59, 130, 246, 0.08);
}

.app-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
}

.localhost-dev-badge {
  color: var(--danger);
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
}

.sub {
  margin: 0;
  color: var(--muted);
  max-width: 70ch;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.stream-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.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-field > select {
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls label > select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls label.renderer-fix-toggle {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

.renderer-fix-toggle input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.info-icon {
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 1.05rem;
  height: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-family: Georgia, serif;
  font-style: italic;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
  user-select: none;
}

/* Smaller select text so long stream group / application labels show more before ellipsis. */
.controls select {
  font-size: 0.78rem;
  padding: 0.4rem 0.5rem;
}

.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;
}

.session-arn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.session-arn #sessionArnText {
  min-width: 0;
}

button.copy-inline {
  flex: none;
  padding: 0.2rem 0.45rem;
  font-size: 0.7rem;
  line-height: 1.3;
}

.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-title {
  max-width: min(42vw, 30rem);
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-stat-sep {
  color: var(--muted);
  user-select: none;
}

/* A stat whose last refresh failed keeps its previous value, greyed. */
.stream-stat-stale {
  color: var(--muted);
}

.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;
}

.admin-shell-panel {
  margin: 0;
}

.admin-shell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.admin-shell-header .stream-debug-title {
  margin: 0;
}

.admin-shell-reconnect {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #1c2430;
  color: var(--muted);
  cursor: pointer;
}

.admin-shell-reconnect:hover {
  color: var(--text);
  border-color: #3d4d62;
}

.admin-shell-terminal {
  width: 100%;
  height: 22rem;
  background: #0b0f14;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

/* Footer row under the terminal: connection timer on the left, hint after it. */
.admin-shell-footer {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.admin-shell-timer {
  flex: none;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.85;
}

.admin-shell-timer.is-disconnected {
  opacity: 0.45;
}

.admin-shell-hint {
  margin: 0;
  font-size: 0.8rem;
}

.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);
}
