:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --panel-2: #222c38;
  --border: #2c3744;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }

html, body, #app {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .5px; }
.status { color: var(--muted); font-size: 13px; }
.status.ok { color: var(--accent-2); }
.badges { margin-left: auto; display: flex; gap: 8px; }
.badge {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.on { background: rgba(34,197,94,.15); color: var(--accent-2); border-color: rgba(34,197,94,.4); }

.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  padding: 16px;
}
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.input, .select {
  width: 100%;
  padding: 9px 11px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); }

.btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); }

.section-title { font-size: 13px; font-weight: 600; margin: 18px 0 10px; color: var(--text); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.error { color: var(--danger); font-size: 12px; margin-top: 8px; }

.device-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 11px; margin-bottom: 8px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px;
}
.device-item.active { border-color: var(--accent); }

.screen-wrap {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.remote-video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.touch-overlay {
  position: absolute;
  inset: 0;
  touch-action: none;
}
.touch-overlay.active { cursor: crosshair; }
.placeholder {
  position: absolute;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 24px;
}
.placeholder .big { font-size: 40px; margin-bottom: 10px; }

.control-bar {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  justify-content: center;
}
.key-btn {
  min-width: 84px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.key-btn:hover { border-color: var(--accent); }
.key-btn:active { background: var(--accent); }

.resolution-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.resolution-label { font-size: 13px; color: var(--text); font-weight: 600; }
.resolution-select {
  padding: 9px 11px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.resolution-select:focus { border-color: var(--accent); }
.resolution-select:disabled { opacity: .5; cursor: not-allowed; }
.resolution-current { font-size: 12px; color: var(--muted); }

.footer { background: var(--panel); border-top: 1px solid var(--border); }
.stats-bar {
  display: flex;
  gap: 18px;
  padding: 10px 18px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.stats-bar b { color: var(--text); font-weight: 600; }
