:root {
  --bg: #0b0e14;
  --panel: #141923;
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #eef2f7;
  --muted: #8b95a5;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
}

* {
  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", "PingFang SC", sans-serif;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Login & Dashboard Views */
.center-view {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.card-wide {
  max-width: 680px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

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

h1 {
  font-size: 20px;
  font-weight: 600;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  margin-bottom: 14px;
}

.input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
  transition: background 0.15s, opacity 0.15s;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn-full {
  width: 100%;
  padding: 12px 16px;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.35);
}

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

/* Dashboard */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.status-pill.offline {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
}

.device-meta h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.device-meta p {
  font-size: 12px;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
  font-size: 14px;
  border: 1px dashed var(--panel-border);
  border-radius: 12px;
}

/* Remote Viewport */
#remote-view {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  user-select: none;
  touch-action: none;
}

#video-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
}

/* Floating HUD */
#hud {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 20, 30, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  max-width: 96vw;
  flex-wrap: nowrap;
  overflow-x: auto;
}

#hud .stat {
  color: #cbd5e1;
  white-space: nowrap;
  padding: 0 4px;
}

#hud .badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-p2p {
  background: rgba(34, 197, 94, 0.22);
  color: #4ade80;
}

.badge-relay {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}

.badge-connecting {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
}

.hud-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.hud-btn.danger {
  background: rgba(239, 68, 68, 0.28);
  color: #fecaca;
}

.hud-select {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}

/* Mobile Quick Key Bar */
#mobile-bar {
  display: none;
  background: rgba(15, 20, 30, 0.92);
  border-top: 1px solid var(--panel-border);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  gap: 8px;
  overflow-x: auto;
  align-items: center;
}

#mobile-bar.active {
  display: flex;
}

.key-btn {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 500;
}

.key-btn:active {
  background: var(--accent);
}

#hidden-keyboard-input {
  position: fixed;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: 0;
}
