:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e6ec;
  --border-hover: #cbd1da;
  --text: #1a2332;
  --text-dim: #4a5568;
  --text-muted: #8895a7;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.12);
  --green: #059669;
  --green-bg: rgba(5, 150, 105, 0.08);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.06);
  --yellow: #d97706;
  --yellow-bg: rgba(217, 119, 6, 0.08);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 32px 24px;
}

.container {
  max-width: 960px;
  margin: 0 auto;
}

/* ── Header ──────────────────────────────────── */

.header {
  margin-bottom: 32px;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  color: var(--text);
}

.header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Cards ───────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Presets ──────────────────────────────────── */

.presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  background: var(--border);
  color: var(--text);
  border-color: var(--border-hover);
}

/* ── Form controls ───────────────────────────── */

.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.form-row:last-child { margin-bottom: 0; }

select, input[type="text"] {
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s ease;
}

select:focus, input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select { cursor: pointer; }

input.host-input { flex: 1; min-width: 200px; }
input.port-input { width: 72px; }
input.fp-input { flex: 1; min-width: 200px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }

.fp-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Toggle switches ─────────────────────────── */

.toggle-group {
  display: flex;
  gap: 16px;
  align-items: center;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  user-select: none;
}

.toggle input { display: none; }

.toggle .switch {
  width: 34px;
  height: 18px;
  background: var(--border);
  border-radius: 9px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle .switch::after {
  content: '';
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: all 0.2s ease;
}

.toggle input:checked + .switch {
  background: var(--accent);
}

.toggle input:checked + .switch::after {
  left: 18px;
  background: #fff;
}

/* ── Buttons ─────────────────────────────────── */

.btn {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #cbd5e1; color: #94a3b8; cursor: not-allowed; }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }
.btn-danger:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Status badge ────────────────────────────── */

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge.on { background: var(--green-bg); color: var(--green); }
.badge.off { background: var(--red-bg); color: var(--red); }
.badge.busy { background: var(--yellow-bg); color: var(--yellow); }

.live-owd {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Video area ──────────────────────────────── */

.video-area {
  display: none;
  gap: 16px;
}

.video-area.active { display: flex; }

.video-box {
  flex: 1;
  min-width: 0;
}

.video-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.video-box video, .video-box img {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0a0e17;
  border-radius: var(--radius);
  display: block;
  object-fit: contain;
  border: 1px solid var(--border);
}

/* ── Results table ───────────────────────────── */

#results table {
  width: 100%;
  border-collapse: collapse;
}

#results th, #results td {
  padding: 10px 14px;
  font-size: 13px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

#results th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--surface-2);
}

#results th:first-child, #results td:first-child { text-align: left; }

#results td {
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-dim);
}

#results td:first-child {
  font-family: inherit;
  color: var(--text);
  font-weight: 500;
}

#results tr:last-child td { border-bottom: none; }

/* ── Log ─────────────────────────────────────── */

#log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 16px;
}

#log:empty { display: none; }

/* ── Scrollbar ───────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd1da; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* ── Tooltips & Info Overlays ─────────────── */

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  font-style: italic;
  font-family: Georgia, serif;
}

.info-icon:hover { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

.tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  font-style: normal;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 8px;
  width: 280px;
  white-space: normal;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 100;
  pointer-events: none;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text);
}

.info-icon:hover .tooltip { display: block; }

/* ── Collapsible Log ─────────────────────── */

.log-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-top: 16px;
  user-select: none;
}

.log-toggle::before {
  content: '▶';
  font-size: 8px;
  transition: transform 0.2s;
}

.log-toggle.open::before { transform: rotate(90deg); }

#log.collapsed { display: none !important; }

/* ── Helper text ─────────────────────────── */

.helper-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Results hint ────────────────────────── */

.results-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-style: italic;
}
