:root {
  color-scheme: dark;
  /* NVIDIA green translucent dark */
  --nv-green: #76b900;
  --nv-green-dim: #5a8f00;
  --nv-green-glow: rgba(118, 185, 0, 0.22);
  --bg: #06140a;
  --bg-glow: radial-gradient(ellipse 120% 80% at 10% -10%, rgba(118, 185, 0, 0.14), transparent 55%),
    radial-gradient(ellipse 90% 60% at 100% 0%, rgba(20, 80, 30, 0.35), transparent 50%),
    linear-gradient(165deg, #041008 0%, #0a1a0e 45%, #06120a 100%);
  --panel: rgba(12, 36, 18, 0.55);
  --panel-solid: rgba(10, 28, 14, 0.82);
  --border: rgba(118, 185, 0, 0.28);
  --border-strong: rgba(118, 185, 0, 0.45);
  --text: #e8f5dc;
  --muted: #8aad7a;
  --accent: #76b900;
  --danger: #ef4444;
  --input-bg: rgba(4, 16, 8, 0.72);
  --hud-bg: rgba(0, 20, 8, 0.45);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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(4, 16, 8, 0.92);
  backdrop-filter: blur(10px);
  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 rgba(118, 185, 0, 0.2);
  border-top-color: var(--nv-green);
  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: #b8e86a;
}

.header {
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 22, 12, 0.55);
  backdrop-filter: blur(12px);
}

.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;
  letter-spacing: 0.01em;
  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(118, 185, 0, 0.08);
}

.app-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: rgba(118, 185, 0, 0.14);
}

.localhost-dev-badge {
  color: var(--danger);
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
}

.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;
  backdrop-filter: blur(14px);
  box-shadow: 0 0 0 1px rgba(118, 185, 0, 0.06), 0 8px 32px rgba(0, 0, 0, 0.35);
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.controls label > select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls select {
  font-size: 0.78rem;
  padding: 0.4rem 0.5rem;
}

.app-list-error {
  margin: 0.35rem 0 0.75rem;
  color: #fca5a5;
  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: var(--input-bg);
  color: var(--text);
  font-size: 0.95rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 2px var(--nv-green-glow);
}

.advanced {
  margin: 0.15rem 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(8, 24, 12, 0.45);
  overflow: hidden;
}

.advanced > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
}

.advanced > summary::-webkit-details-marker {
  display: none;
}

.advanced > summary::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex: none;
}

.advanced[open] > summary::before {
  transform: rotate(45deg);
}

.advanced > summary:hover {
  color: var(--text);
  background: rgba(118, 185, 0, 0.07);
}

.advanced-body {
  padding: 0.35rem 0.65rem 0.75rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 0.6rem;
}

.advanced-body label {
  margin-bottom: 0.6rem;
  min-width: 0;
}

.advanced-body .advanced-check {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  grid-column: 1 / -1;
  cursor: pointer;
}

.advanced-body .advanced-check input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.advanced-body .advanced-overrides {
  grid-column: 1 / -1;
}

.advanced-body .advanced-overrides input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

/* Let info-tip bubbles escape the details box while it is open
   (closed state keeps overflow:hidden so the rounded corners clip).
   Also lift the open panel above following controls so bubbles are not
   painted under later selects / the stream column. */
.panel.controls {
  overflow: visible;
}

.advanced-body,
.advanced-body label,
.advanced-body .label-row {
  overflow: visible;
}

.advanced[open] {
  overflow: visible;
  position: relative;
  z-index: 5;
}

.advanced-body .label-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  position: relative;
}

.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 0.95rem;
  height: 0.95rem;
  border: 1px solid var(--muted);
  border-radius: 50%;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.62rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  user-select: none;
  z-index: 1;
}

.info-tip:hover,
.info-tip:focus,
.info-tip:focus-visible {
  border-color: var(--nv-green);
  color: var(--nv-green);
  outline: none;
  z-index: 30;
}

/* Bubble opens below the icon so it stays inside the open details body
   (upward placement was clipped by summary / panel backdrop-filter).
   Centered on the icon so long copy stays readable in the narrow sidebar. */
.info-tip-bubble {
  position: absolute;
  top: calc(100% + 0.4rem);
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: max-content;
  max-width: min(18rem, 70vw);
  padding: 0.5rem 0.65rem;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-family: inherit;
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  white-space: normal;
  overflow-wrap: anywhere;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.info-tip:hover .info-tip-bubble,
.info-tip:focus .info-tip-bubble,
.info-tip:focus-visible .info-tip-bubble {
  opacity: 1;
  visibility: visible;
}

.info-tip-bubble::after {
  content: "";
  position: absolute;
  bottom: 100%;
  top: auto;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom-color: var(--border);
}

@media (max-width: 420px) {
  .advanced-body {
    grid-template-columns: 1fr;
  }
}

.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: rgba(18, 48, 24, 0.75);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  backdrop-filter: blur(6px);
}

button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: rgba(28, 64, 32, 0.85);
}

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

button.primary {
  background: rgba(118, 185, 0, 0.85);
  border-color: var(--nv-green-dim);
  color: #041008;
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: var(--nv-green);
}

button.danger {
  background: rgba(80, 20, 20, 0.55);
  border-color: #7f1d1d;
  color: #fecaca;
}

.session-id {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.session-id #sessionIdText {
  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;
  background: rgba(0, 12, 6, 0.65);
}

.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;
}

.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: #c8e8b0;
  border-top: 1px solid var(--border);
  background: var(--hud-bg);
}

.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;
}

.stream-zone-info {
  margin: 0;
  padding: 0.4rem 0.75rem 0.15rem;
  font-size: 0.8rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: rgba(0, 16, 8, 0.35);
  word-break: break-word;
}

.stream-zone-info.is-mismatch {
  color: #f0c674;
}

.stream-zone-info[hidden] {
  display: 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: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #c8e8b0;
  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, 16, 8, 0.35);
}
