* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1419;
  --card: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
}
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
header {
  text-align: center;
  margin-bottom: 28px;
}
header h1 { font-size: 1.5rem; font-weight: 600; }
header p { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 1rem; margin-bottom: 14px; color: var(--muted); font-weight: 500; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.form-row input, .form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
.form-row input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn {
  background: #f59e0b;
  color: #1a1a1a;
  font-weight: 600;
}
.btn-warn:active:not(:disabled) { background: #d97706; }
.btn-warn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-warn.active { background: #dc2626; color: #fff; }
.btn-call {
  background: #10b981;
  color: #fff;
  font-weight: 600;
}
.btn-call:hover:not(:disabled) { background: #059669; }
.btn-call.active { background: #ef4444; }
.btn-call.active:hover:not(:disabled) { background: #dc2626; }
.btn-call:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-video {
  background: #6366f1;
  color: #fff;
  font-weight: 600;
}
.btn-video:hover:not(:disabled) { background: #4f46e5; }
.btn-video.active { background: #ef4444; }
.btn-video.active:hover:not(:disabled) { background: #dc2626; }
.btn-video:disabled { opacity: 0.5; cursor: not-allowed; }
.status {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-top: 12px;
}
.status.info { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.status.ok { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.status.err { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.video-wrap {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16/9;
  margin-top: 16px;
}
.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.video-wrap video.mirror {
  transform: scaleX(-1);
}
.video-pip.local-pip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 28%;
  max-width: 200px;
  min-width: 100px;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #6366f1;
  z-index: 2;
  background: #000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}
.video-wrap .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  margin-left: 8px;
}
.badge.live { background: var(--danger); color: #fff; animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: 0.7; } }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }
.link-box {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.85rem;
  word-break: break-all;
  margin-top: 10px;
}
.device-list { display: flex; flex-direction: column; gap: 10px; }
.device-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.device-item .device-id { font-size: 0.8rem; color: var(--muted); margin-top: 4px; font-family: Consolas, monospace; }
.tag { font-size: 0.75rem; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.tag.on { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.tag.wait { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.tag.off { background: rgba(100, 116, 139, 0.3); color: #94a3b8; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-row { margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mirror-toggle { font-size: 0.85rem; color: var(--muted); cursor: pointer; user-select: none; }
.mirror-toggle input { margin-right: 4px; vertical-align: middle; }
.device-id-box {
  font-family: Consolas, monospace;
  font-size: 1.1rem;
  letter-spacing: 1px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  user-select: all;
}
