:root {
  --bg: #0a0a0b;
  --surface: #111113;
  --surface-2: #18181b;
  --border: #27272a;
  --border-strong: #3f1818;
  --text: #fafafa;
  --muted: #71717a;
  --accent: #be123c;
  --accent-bright: #e11d48;
  --accent-soft: rgba(190, 18, 60, 0.12);
  --live: #22c55e;
  --warn: #eab308;
  --font-display: "Syne", "Segoe UI", sans-serif;
  --font-body: "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(190, 18, 60, 0.04) 0%, transparent 28%),
    var(--bg);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--accent-bright);
  display: grid;
  place-items: center;
}

.logo svg {
  width: 22px;
  height: 22px;
}

h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

.status-pill.connected .dot {
  background: var(--live);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.55);
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0.85rem;
  padding: 0.85rem;
  min-height: 0;
}

.video-panel {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

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

#remoteVideo {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #000;
  display: block;
  transform-origin: center center;
  transition: transform 0.12s ease-out;
}

.fx-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 1;
}

.video-overlay.hidden {
  opacity: 0;
}

.overlay-inner {
  text-align: center;
  padding: 1rem;
}

.overlay-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

.overlay-hint {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.stats-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.88));
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #a1a1aa;
  z-index: 3;
}

.stat-sep {
  opacity: 0.35;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
}

.card-connect {
  border-color: var(--border-strong);
}

.card-muted {
  background: transparent;
  border-style: dashed;
}

.card-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.card h2 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.hint.compact {
  margin-top: 0.65rem;
  font-size: 0.78rem;
}

.relay-note {
  margin-bottom: 0.45rem;
  font-size: 0.8rem;
}

.relay-note.active {
  color: var(--accent-bright);
}

.connect-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  margin: 0.65rem 0;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.connect-status.ready {
  border-color: var(--border-strong);
  color: var(--text);
}

.connect-status .status-icon {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.connect-status.ready .status-icon {
  background: var(--accent-bright);
}

.connect-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.phone-troubleshoot {
  margin-top: 0.55rem;
  font-size: 0.76rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
}

.qr-wrap {
  display: grid;
  place-items: center;
  padding: 0.75rem;
  background: #fff;
  border-radius: 8px;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
}

.btn {
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-body);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  margin-top: 0.45rem;
}

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

.btn.ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.ghost:hover {
  border-color: var(--border-strong);
  color: #fff;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
  color: var(--text);
  margin-top: 0.6rem;
  cursor: pointer;
}

.toggle-row input {
  accent-color: var(--accent-bright);
  width: 15px;
  height: 15px;
}

.range-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.range-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.range-label strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 500;
}

.range-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent-bright);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  body {
    overflow-y: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .main {
    grid-template-columns: 1fr;
  }

  .video-panel {
    min-height: 220px;
    max-height: 50vh;
  }

  .sidebar {
    overflow-y: visible;
  }
}
