:root {
  --bg: #07090f;
  --surface: rgba(17, 24, 39, 0.88);
  --border: rgba(255, 255, 255, 0.1);
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --emerald: #10b981;
  --danger: #ef4444;
  --text: #f8fafc;
  --muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Lobby Screen */
.lobby {
  height: 100%;
  overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background: radial-gradient(circle at 80% 0%, #172554 0%, #07090f 55%);
}

.lobby-inner {
  max-width: 980px;
  margin: 0 auto;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.brand h1 { font-size: 20px; font-weight: 700; }
.brand p { font-size: 12px; color: var(--muted); margin-top: 2px; }

.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; }
.conn-dot.online { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.conn-dot.offline { background: var(--danger); }

.lobby-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 18px;
}
@media (max-width: 780px) {
  .lobby-grid { grid-template-columns: 1fr; }
}

.panel {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(12px);
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.host-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.host-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 0.15s, background 0.15s;
}
.host-card:hover {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.08);
}

.host-meta h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.host-meta p { font-size: 12px; color: var(--muted); }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 9, 15, 0.75);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.input:focus { border-color: var(--accent); }

.btn {
  padding: 9px 16px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s;
}
.btn:hover { background: var(--accent-hover); }
.btn-subtle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
}
.btn-subtle:hover { background: rgba(255, 255, 255, 0.14); }
.btn-danger { background: var(--danger); }

/* Remote Session Stage */
.stage {
  position: fixed;
  inset: 0;
  background: #000;
  display: none;
  overflow: hidden;
  touch-action: none;
}
.stage.active { display: block; }

.screens-grid {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transform-origin: center center;
}
.screens-grid.split-row { flex-direction: row; }
.screens-grid.split-col { flex-direction: column; }

.screen-pane {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

.screen-pane video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: default;
}

.pane-badge {
  position: absolute;
  bottom: 10px;
  left: 12px;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  pointer-events: none;
}

/* UU-Style Floating Top Capsule Bar */
.floating-bar {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.capsule-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

.toolbar-drawer {
  margin-top: 8px;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  max-width: 96vw;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65);
}
.floating-bar.expanded .toolbar-drawer { display: flex; }

.tb-select, .tb-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}
.tb-select option { background: #0f172a; color: #f8fafc; }
.tb-btn:hover { background: rgba(255, 255, 255, 0.15); }
.tb-btn.active {
  background: rgba(59, 130, 246, 0.3);
  border-color: #60a5fa;
  color: #93c5fd;
}
.tb-btn.danger {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

/* Virtual Cursor for iOS Trackpad Mode */
.virtual-cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 45;
  pointer-events: none;
  display: none;
  will-change: transform;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.65));
}

/* iOS / Touch Floating Shortcut Dock */
.ios-dock {
  position: fixed;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  display: none;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  max-width: 98vw;
  overflow-x: auto;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(14px);
}
.ios-dock.visible { display: flex; }

.key-chip {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 600;
}
.key-chip.latched {
  background: var(--accent);
  border-color: #93c5fd;
}

/* Hidden offscreen input to summon iOS soft keyboard & Pinyin IME */
.ime-bridge {
  position: fixed;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
}

/* Custom Keymap Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  width: 100%;
  max-width: 420px;
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}
.map-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
}
