* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: #0a0a0a;
  color: #eee;
  overflow: hidden;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: #151515;
  border-bottom: 1px solid #2a2a2a;
  flex: 0 0 auto;
}

#topbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#topbar label {
  font-size: 0.85rem;
  color: #aaa;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#topbar select {
  background: #222;
  color: #eee;
  border: 1px solid #333;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

#focused-output {
  font-size: 0.85rem;
  color: #8af;
  padding: 0.2rem 0.6rem;
  background: #10151c;
  border: 1px solid #1e2a3a;
  border-radius: 3px;
}

#refresh-btn {
  background: #1a1a1a;
  color: #aaa;
  border: 1px solid #2a2a2a;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 3px;
}

#refresh-btn:hover { background: #222; color: #eee; }
#refresh-btn:active { background: #333; }
#refresh-btn.refreshing { color: #08f; border-color: #08f; }

#logout-link {
  font-size: 0.75rem;
  color: #888;
  text-decoration: none;
  padding: 0.2rem 0.4rem;
}

#logout-link:hover { color: #eee; }

#connection-status {
  margin-left: auto;
  font-size: 0.8rem;
  color: #888;
  font-family: ui-monospace, Menlo, monospace;
}

#connection-status.connected { color: #6c6; }
#connection-status.disconnected { color: #c66; }

#take-btn {
  background: #c00;
  color: white;
  border: none;
  padding: 0.5rem 1.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  letter-spacing: 0.08em;
}

#take-btn:hover:not(:disabled) { background: #e00; }
#take-btn:disabled { background: #444; color: #888; cursor: not-allowed; }

main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  height: calc(100% - 56px - 36px);
  overflow: hidden;
}

#sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  grid-auto-rows: min-content;
  gap: 0.5rem;
  overflow-y: auto;
  align-content: start;
  align-items: start;
  flex: 1 1 auto;
}

.tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 4px solid #222;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 80ms linear;
  user-select: none;
}

.tile:hover { border-color: #333; }
.tile.selected { border-color: #08f; }
.tile.armed { border-color: #0c0; }
.tile.on-air { border-color: #f22; }
.tile.on-air.armed { border-color: #f22; box-shadow: inset 0 0 0 2px #0c0; }

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.tile .tile-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  pointer-events: none;
}

.tile .umd {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.3rem 0.5rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  font-size: 0.8rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tile .umd .index {
  background: #fff;
  color: #000;
  padding: 0 0.35rem;
  border-radius: 2px;
  font-weight: 700;
  min-width: 1.3rem;
  text-align: center;
}

.tile .umd .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile .umd .status {
  font-size: 0.7rem;
  padding: 0 0.3rem;
  border-radius: 2px;
}

.tile .umd .status.online { color: #8f8; background: rgba(0, 80, 0, 0.5); }
.tile .umd .status.offline { color: #888; background: rgba(40, 40, 40, 0.6); }
.tile .umd .status.paused { color: #fc3; background: rgba(80, 60, 0, 0.5); }

#outputs-rack {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem;
  background: #111;
  border: 1px solid #222;
  flex: 0 0 auto;
  max-height: 140px;
}

.output-card {
  flex: 0 0 220px;
  padding: 0.5rem 0.6rem;
  background: #1a1a1a;
  border: 2px solid #2a2a2a;
  cursor: pointer;
  border-radius: 2px;
}

.output-card.focused {
  border-color: #08f;
  background: #142030;
}

.output-card .output-header {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.output-card .output-header .index {
  background: #08f;
  color: #000;
  padding: 0 0.35rem;
  border-radius: 2px;
  font-weight: 700;
  min-width: 1.3rem;
  text-align: center;
}

.output-card .output-header .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-card .pvw,
.output-card .pgm {
  font-size: 0.75rem;
  padding: 0.15rem 0.3rem;
  display: flex;
  gap: 0.4rem;
}

.output-card .pvw {
  color: #8f8;
  border-left: 3px solid #0c0;
  background: rgba(0, 60, 0, 0.15);
}

.output-card .pgm {
  color: #f99;
  border-left: 3px solid #f22;
  background: rgba(80, 0, 0, 0.2);
  margin-top: 0.15rem;
}

.output-card .pvw .label,
.output-card .pgm .label {
  font-weight: 700;
  opacity: 0.7;
  min-width: 2.2rem;
}

.output-card .pvw .value,
.output-card .pgm .value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-card .drift-badge {
  display: none;
  color: #fc3;
  font-size: 0.7rem;
  margin-top: 0.2rem;
}

.output-card.drift .drift-badge { display: block; }

#shortcut-hint {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.4rem 1rem;
  background: #0f0f0f;
  border-top: 1px solid #222;
  font-size: 0.75rem;
  color: #666;
  text-align: center;
}

#shortcut-hint kbd {
  background: #222;
  border: 1px solid #333;
  padding: 0 0.3rem;
  border-radius: 2px;
  font-family: ui-monospace, Menlo, monospace;
  color: #aaa;
}

#build-info {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: ui-monospace, Menlo, monospace;
  color: #555;
  font-size: 0.7rem;
}

/* --- login screen --- */

#login-shell {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

#login-card {
  width: 100%;
  max-width: 320px;
  padding: 2rem;
  background: #151515;
  border: 1px solid #252525;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#login-card h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#login-card .subhead {
  margin: 0;
  font-size: 0.85rem;
  color: #888;
}

#login-card input[type="password"] {
  background: #0c0c0c;
  border: 1px solid #2a2a2a;
  color: #eee;
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  border-radius: 3px;
  outline: none;
  transition: border-color 100ms ease;
}

#login-card input[type="password"]:focus {
  border-color: #08f;
}

#login-card button[type="submit"] {
  background: #c00;
  color: #fff;
  border: none;
  padding: 0.7rem 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 3px;
  transition: background 100ms ease;
}

#login-card button[type="submit"]:hover {
  background: #e00;
}

#login-card .login-error {
  background: rgba(180, 0, 0, 0.15);
  border: 1px solid rgba(255, 60, 60, 0.4);
  color: #f99;
  padding: 0.5rem 0.7rem;
  border-radius: 3px;
  font-size: 0.85rem;
}

