:root {
  --bg: #10141c;
  --surface: #1a2029;
  --surface-2: #222a36;
  --border: #2b3441;
  --text: #e8ecf3;
  --text-dim: #8b95a5;
  --accent: #4fd1c5;
  --accent-dim: #2b6f68;
  --danger: #e5584f;
  --radius: 14px;
  font-family: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, .brand-name { font-family: 'Space Grotesk', system-ui, sans-serif; }

/* ---------- Landing ---------- */

body.landing {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.landing-glow {
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 900px;
  background: radial-gradient(circle, rgba(79, 209, 197, 0.16) 0%, rgba(79, 209, 197, 0) 65%);
  pointer-events: none;
}

.join-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}

.brand { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.brand-dot.small { width: 8px; height: 8px; }
.brand-name { font-weight: 600; letter-spacing: 0.02em; color: var(--text-dim); font-size: 14px; }

.join-card h1 {
  font-size: 32px;
  line-height: 1.15;
  margin: 0 0 12px;
  font-weight: 600;
}

.sub { color: var(--text-dim); font-size: 14.5px; line-height: 1.5; margin: 0 0 28px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  margin-top: 8px;
  background: var(--accent);
  color: #08211f;
  border: none;
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.15s, transform 0.1s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  width: 100%;
  margin-top: 14px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-ghost:hover { color: var(--text); }

/* ---------- Call room ---------- */

body.call { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.room-name { font-weight: 600; font-size: 14.5px; }

.status-pill {
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.status-pill.connecting { background: rgba(255,193,84,0.15); color: #ffc154; }
.status-pill.connected { background: rgba(79,209,197,0.15); color: var(--accent); }
.status-pill.disconnected { background: rgba(229,88,79,0.15); color: var(--danger); }

.participant-count { font-size: 13px; color: var(--text-dim); }

.btn-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.btn-chip:hover { border-color: var(--accent); }

.stage { flex: 1; display: flex; overflow: hidden; }

.video-grid {
  flex: 1;
  display: grid;
  gap: 10px;
  padding: 16px;
  grid-template-columns: repeat(1, 1fr);
  align-content: center;
  overflow-y: auto;
}
.video-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.video-grid[data-count="3"],
.video-grid[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.video-grid[data-count="5"],
.video-grid[data-count="6"] { grid-template-columns: repeat(3, 1fr); }
.video-grid[data-count="7"],
.video-grid[data-count="8"],
.video-grid[data-count="9"] { grid-template-columns: repeat(3, 1fr); }
.video-grid[data-count="9plus"] { grid-template-columns: repeat(4, 1fr); }

.tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  min-height: 140px;
}
.tile.sharing { grid-column: 1 / -1; grid-row: span 2; aspect-ratio: 16/9; }

.tile-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #0c0f15; }
.tile-media video { width: 100%; height: 100%; object-fit: cover; }
.tile.sharing .tile-media video.screen-video { object-fit: contain; background: #000; }

/* I-mirror lang ang sariling camera preview, hindi ang remote participants */
.local-cam {
  transform: scaleX(-1);
}
/* I-mirror lang ang sariling video preview, hindi ang remote participants */
.tile.local-tile .tile-media video {
  transform: scaleX(-1);
}

.tile-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 13, 20, 0.6);
  backdrop-filter: blur(6px);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
}
.tile-mic-off { display: none; font-size: 12px; }

/* ---------- Chat panel ---------- */

.chat-panel {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.chat-panel.hidden { display: none; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.icon-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 15px; }
.icon-btn:hover { color: var(--text); }

.chat-messages { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-line { font-size: 13.5px; line-height: 1.4; }
.chat-sender { display: block; font-size: 11.5px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.chat-line.me .chat-sender { color: var(--text-dim); }
.chat-text { color: var(--text); word-break: break-word; }

.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-form input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}
.chat-form input:focus { border-color: var(--accent); }

/* ---------- Bottom controls ---------- */

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.ctrl-btn svg { width: 20px; height: 20px; }
.ctrl-btn:hover { border-color: var(--accent); color: var(--text); }
.ctrl-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.ctrl-btn.leave { background: rgba(229,88,79,0.12); border-color: var(--danger); color: var(--danger); }
.ctrl-btn.leave:hover { background: var(--danger); color: #fff; }

@media (max-width: 640px) {
  .chat-panel { position: fixed; inset: 0; width: 100%; z-index: 20; }
  .ctrl-btn span { display: none; }
  .ctrl-btn { padding: 12px; }
  .topbar-right .btn-chip { display: none; }
}
