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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --green: #22c55e;
  --radius: 12px;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
}

/* ── Home page ──────────────────────────────────────────────────────────── */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  gap: 20px;
}

.home-container h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card h2 { font-size: 1.1rem; font-weight: 600; }

.divider {
  color: var(--text-muted);
  font-size: 0.85rem;
  position: relative;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

.input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 11px 20px;
  transition: background 0.15s, transform 0.1s;
  width: 100%;
}
.btn:active { transform: scale(0.98); }

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

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--surface); }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: color 0.15s, background 0.15s;
  width: auto;
}
.btn-icon:hover { background: var(--surface); color: var(--text); }

/* ── Room page ──────────────────────────────────────────────────────────── */
.room-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.room-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  padding: 12px 20px;
}

.room-title { font-size: 1.1rem; font-weight: 700; }

.room-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.room-id {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: monospace;
}

/* ── Status badge ───────────────────────────────────────────────────────── */
.status-badge {
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
}
.status-badge.connecting { background: #854d0e; color: #fef08a; }
.status-badge.connected  { background: #14532d; color: #86efac; }
.status-badge.disconnected { background: #7f1d1d; color: #fca5a5; }

/* ── Video grid ─────────────────────────────────────────────────────────── */
.video-grid {
  flex: 1;
  display: grid;
  gap: 8px;
  padding: 12px;
  overflow: hidden;
  place-content: center;
}

.video-wrapper {
  position: relative;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-wrapper.local video {
  transform: scaleX(-1); /* mirror self */
}

.video-label {
  position: absolute;
  bottom: 8px;
  left: 10px;
  background: rgba(0,0,0,0.55);
  border-radius: 6px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
}

/* ── Error banner ───────────────────────────────────────────────────────── */
.error-banner {
  background: #450a0a;
  border-top: 1px solid var(--danger);
  color: #fca5a5;
  font-size: 0.875rem;
  padding: 10px 20px;
  text-align: center;
}
.error-banner.hidden { display: none; }

/* ── Controls bar ───────────────────────────────────────────────────────── */
.controls {
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
}

.control-btn {
  align-items: center;
  background: var(--border);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  height: 52px;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  width: 52px;
}
.control-btn:active { transform: scale(0.93); }
.control-btn:not(.active):not(.leave) { background: #374151; color: #9ca3af; }
.control-btn.active { background: #1d4ed8; }
.control-btn.leave { background: var(--danger); }
.control-btn.leave:hover { background: var(--danger-hover); }

.hidden { display: none !important; }

/* ── Responsive tweaks ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .room-header { padding: 10px 12px; }
  .room-id { display: none; }
  .video-grid { padding: 6px; gap: 4px; }
  .controls { padding: 12px; gap: 12px; }
  .control-btn { height: 46px; width: 46px; }
}
