:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080b12;
  color: #f5f7fb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(110, 61, 255, .22), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(0, 205, 255, .15), transparent 32rem),
    #080b12;
}
.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}
.brand { font-weight: 900; letter-spacing: .08em; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  color: #bcc6d8;
  font-size: 13px;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #637083;
}
.dot.online { background: #4ee59b; box-shadow: 0 0 18px rgba(78,229,155,.65); }
.hero {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 22px;
}
.card {
  background: rgba(16, 20, 31, .86);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.24);
}
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(30px, 5vw, 54px); line-height: 1; margin-bottom: 16px; }
h2 { font-size: 18px; margin-bottom: 16px; }
.muted { color: #9da9bd; }
.room-code {
  font-size: clamp(34px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: .16em;
  text-align: center;
  padding: 24px 10px;
  border-radius: 18px;
  background: #0b0f18;
  border: 1px dashed rgba(255,255,255,.18);
}
.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
button, input {
  width: 100%;
  min-height: 48px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,.12);
  font: inherit;
}
button {
  cursor: pointer;
  font-weight: 800;
  color: #fff;
  background: #6d4aff;
}
button.secondary { background: #171d2b; }
button.danger { background: #a72c45; }
button:disabled { opacity: .45; cursor: not-allowed; }
input {
  background: #0c111b;
  color: #fff;
  padding: 0 14px;
  outline: none;
}
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.stat {
  background: #0c111b;
  border-radius: 14px;
  padding: 14px;
}
.stat strong { display: block; font-size: 22px; }
.stat span { color: #92a0b5; font-size: 12px; }
.log {
  height: 220px;
  overflow: auto;
  background: #070a10;
  border-radius: 14px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #aebbd0;
  white-space: pre-wrap;
}
.screen {
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.09);
  background: #020305;
}
.screen h1 { margin: 0 0 10px; }
.kicker {
  color: #8aa0c0;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: 12px;
}
@media (max-width: 780px) {
  .hero { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .status-grid { grid-template-columns: 1fr; }
}

.stack { display: grid; gap: 22px; margin-top: 22px; }
.agent-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 22px; }
.agent-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-radius: 14px;
  background: #0c111b;
  margin-bottom: 14px;
}
.agent-state strong { font-size: 18px; }
.agent-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .14em;
}
.results { display: grid; gap: 9px; margin-top: 14px; max-height: 420px; overflow: auto; }
.result {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid rgba(255,255,255,.08);
  background: #0b1019;
  border-radius: 14px;
}
.result-title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-meta { color: #91a0b5; font-size: 12px; margin-top: 4px; }
.result button { width: auto; min-height: 38px; padding: 0 14px; }
.inline-note { font-size: 12px; color: #8f9cb0; margin-top: 9px; }
.good { color: #4ee59b; }
.warn { color: #ffca66; }
@media (max-width: 780px) {
  .agent-grid { grid-template-columns: 1fr; }
  .result { grid-template-columns: 1fr; }
  .result button { width: 100%; }
}

select {
  width: 100%;
  min-height: 48px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,.12);
  background: #0c111b;
  color: #fff;
  padding: 0 14px;
  font: inherit;
}
.stage-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  background: #0c111b;
  border-radius: 14px;
}
.trace-line {
  margin-top: 12px;
  font-size: 12px;
  color: #8795aa;
  overflow-wrap: anywhere;
}
.trace-line code { color: #c7d2e6; }
.diag-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}
.diag-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  min-width: min(100%, 480px);
}
.diag-summary {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #9da9bd;
}
.diag-log { height: 520px; }
.tv-body { background: #030407; }
.tv-shell { width: min(1440px, calc(100% - 24px)); padding-top: 18px; }
.tv-layout { display: grid; grid-template-columns: 340px minmax(0,1fr); gap: 16px; }
.tv-pair-card { align-self: start; }
.tv-screen {
  position: relative;
  min-height: min(72vh, 820px);
  overflow: hidden;
  padding: 0;
  background: #000;
}
.tv-cdg, .tv-video {
  width: 100%;
  height: 100%;
  max-height: 82vh;
  object-fit: contain;
  image-rendering: pixelated;
  background: #000;
}
.tv-cdg { aspect-ratio: 4 / 3; }
.tv-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 32px;
}
.tv-overlay {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(8px);
  font-size: 12px;
  pointer-events: none;
}
.tv-overlay strong { letter-spacing: .12em; }
.preload-meter {
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  color: #aab6c9;
}
.tv-diag-card { margin-top: 16px; }
.compact-log { height: 180px; margin-top: 12px; }
.hidden { display: none !important; }
@media (max-width: 900px) {
  .diag-head { flex-direction: column; }
  .diag-actions { min-width: 0; width: 100%; grid-template-columns: 1fr; }
  .tv-layout { grid-template-columns: 1fr; }
  .tv-screen { min-height: 56vh; }
}
