:root {
  --bg-dark: #080c14;
  --panel-bg: #101726;
  --panel-border: #1e293b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --cyan: #38bdf8;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --purple: #a855f7;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: #0b111e;
  border-bottom: 1px solid var(--panel-border);
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  background: var(--emerald);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--emerald);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-proto {
  font-size: 0.72rem;
  background: rgba(56, 189, 248, 0.14);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 3px 8px;
  border-radius: 4px;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.kpi-strip {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.kpi-box {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 8px 14px;
  border-radius: 6px;
  min-width: 165px;
}

.kpi-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.kpi-val {
  font-size: 1.02rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.accent-cyan { color: var(--cyan); }
.accent-green { color: var(--emerald); }
.accent-amber { color: var(--amber); }
.accent-emerald { color: #34d399; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 18px;
  padding: 18px 24px;
}

@media (max-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-header h2 {
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.mt-section {
  margin-top: 18px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  background: rgba(56, 189, 248, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-action:hover {
  background: rgba(56, 189, 248, 0.24);
}

.btn-cam {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
}

.btn-screen {
  background: rgba(168, 85, 247, 0.16);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.45);
}

.btn-stop {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.55);
}

.viewer-name-box {
  display: flex;
  gap: 6px;
  align-items: center;
}

.viewer-name-box input {
  background: #0b111e;
  border: 1px solid #2b3b55;
  color: var(--text-main);
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.row-you {
  background: rgba(56, 189, 248, 0.09);
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #26354d;
  background: #05080f;
}

#video-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.hud-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(8, 12, 20, 0.82);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 10px 14px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.76rem;
  line-height: 1.55;
  pointer-events: none;
}

.tag-ok {
  color: var(--emerald);
  font-weight: 700;
}

.telemetry-counters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.counter-card {
  background: #0b111e;
  border: 1px solid var(--panel-border);
  padding: 10px;
  border-radius: 6px;
}

.c-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.c-num {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--text-main);
}

.preset-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.btn-preset {
  background: #162033;
  color: var(--text-main);
  border: 1px solid #2b3b55;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 0.76rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s;
}

.btn-preset:hover, .btn-preset.active {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.16);
}

.btn-preset.warn { border-color: rgba(245, 158, 11, 0.45); }
.btn-preset.danger { border-color: rgba(244, 63, 94, 0.45); }

.slider-group {
  margin: 10px 0;
  font-size: 0.82rem;
}

.slider-group input[type="range"] {
  width: 100%;
  margin-top: 6px;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.config-field label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.config-field select {
  width: 100%;
  background: #0b111e;
  color: var(--text-main);
  border: 1px solid #2b3b55;
  padding: 7px 9px;
  border-radius: 5px;
  font-size: 0.78rem;
}

.subgroup-table-wrap {
  overflow-x: auto;
}

.subgroup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-family: ui-monospace, monospace;
}

.subgroup-table th, .subgroup-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
}

.subgroup-table th {
  color: var(--text-muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.state-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}

.state-forwarding {
  background: rgba(16, 185, 129, 0.16);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.state-pruned {
  background: rgba(244, 63, 94, 0.15);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.state-capped {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.preset-badge {
  font-family: ui-monospace, monospace;
  font-size: 0.74rem;
  color: var(--cyan);
}

/* Multi-Stream Grid & Tiles */
.multi-stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stream-tile {
  background: #070c17;
  border: 1px solid #26354d;
  border-radius: 7px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stream-tile.pinned {
  grid-column: 1 / -1;
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.22);
}

.stream-tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  background: #0b1222;
  border-bottom: 1px solid #1e293b;
  font-size: 0.76rem;
}

.stream-tile-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.stream-kind-badge {
  font-size: 0.66rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
}

.kind-webcam {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.kind-screen {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.stream-tile-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #04070e;
  overflow: hidden;
}

.stream-tile-media video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  z-index: 1;
}

.stream-tile-media canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  z-index: 2;
}

.stream-tile-hud {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(8, 12, 20, 0.84);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 5px 10px;
  border-radius: 5px;
  font-family: ui-monospace, monospace;
  font-size: 0.71rem;
  pointer-events: none;
}

.btn-pin {
  background: rgba(56, 189, 248, 0.14);
  color: var(--cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-pin:hover,
.btn-pin.active {
  background: rgba(56, 189, 248, 0.3);
  color: #fff;
}

/* Ephemeral Multi-Room Lobby Bar */
.room-lobby-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: #0d1526;
  border-bottom: 1px solid var(--panel-border);
  flex-wrap: wrap;
  gap: 12px;
}

.room-lobby-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.room-lobby-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.active-rooms-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.room-pill {
  background: #162033;
  color: var(--text-main);
  border: 1px solid #2b3b55;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-family: ui-monospace, monospace;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.12s;
}

.room-pill:hover {
  border-color: var(--cyan);
}

.room-pill.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--cyan);
  color: var(--cyan);
  font-weight: 700;
}

.room-lobby-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-lobby-right input {
  background: #090e1a;
  border: 1px solid #2b3b55;
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 0.76rem;
}
