:root {
  --bg: #0e1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1e2530;
  --border: #2a313d;
  --text: #e6e9ef;
  --text-dim: #9aa4b2;
  --accent: #4f7cff;
  --accent-hover: #6690ff;
  --danger: #e5484d;
  --danger-hover: #ff5c60;
  --ok: #2ecc71;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

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

body.landing {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, #141a24 0%, #0e1117 60%);
}

.landing-header {
  padding: 20px 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 18px;
}

.landing-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.hero {
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.hero h1 {
  font-size: 32px;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.hero p {
  color: var(--text-dim);
  margin-bottom: 28px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: left;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s, transform 0.05s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--accent); color: white; width: 100%; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #262e3b; }

.btn-sm { padding: 8px 14px; font-size: 14px; }

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-dim);
  margin: 20px 0;
  font-size: 13px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.divider span { padding: 0 12px; }

.join-form {
  display: flex;
  gap: 8px;
}

.join-form input, .name-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
}
.join-form input:focus, .name-row input:focus, .chat-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.name-row {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.name-row label {
  font-size: 12px;
  color: var(--text-dim);
}

.landing-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 12px;
}

/* ---------- Room page ---------- */

body.room-body {
  height: 100vh;
  overflow: hidden;
}

.room {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.room-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

.room-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-sm {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
}

.room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-dim);
  font-size: 13px;
  background: var(--bg-elev-2);
  padding: 4px 10px;
  border-radius: 6px;
}

.chip-btn {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
}
.chip-btn:hover { background: #262e3b; }

.room-clock {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.room-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

.video-grid {
  flex: 1;
  display: grid;
  gap: 10px;
  padding: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  grid-auto-rows: 1fr;
  align-content: stretch;
  overflow: auto;
}

.video-tile {
  position: relative;
  background: #12161d;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-tile.speaking {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 124, 255, 0.5);
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-tile.cam-off video { display: none; }

.avatar-fallback {
  display: none;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
}
.video-tile.cam-off .avatar-fallback { display: flex; }

.tile-label {
  position: absolute;
  left: 10px;
  bottom: 8px;
  background: rgba(0,0,0,0.55);
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile-badges {
  position: absolute;
  right: 10px;
  top: 8px;
  display: flex;
  gap: 6px;
  font-size: 13px;
}

.mic-off-badge {
  background: rgba(229, 72, 77, 0.85);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.hand-badge {
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.host-tag {
  font-size: 10px;
  color: #ffd76a;
}

.screen-badge {
  position: absolute;
  left: 10px;
  top: 8px;
  background: rgba(79, 124, 255, 0.85);
  color: white;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

/* Side panel */
.side-panel {
  width: 320px;
  border-left: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
}
.side-panel[data-open="none"] { display: none; }

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.tabs { display: flex; gap: 4px; }
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}
.tab-btn.active { color: var(--text); background: var(--bg-elev-2); }

.close-panel {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
}
.close-panel:hover { color: var(--text); }

.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tab-content.hidden { display: none; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg .who {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}
.chat-msg .when {
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 6px;
  font-size: 11px;
}
.chat-msg .body {
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}
.chat-msg.me .who { color: var(--ok); }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.chat-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
}

.people-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
}
.people-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 14px;
}
.people-list li:hover { background: var(--bg-elev-2); }
.people-list .p-name { display: flex; align-items: center; gap: 8px; }
.people-list .p-status { display: flex; gap: 6px; color: var(--text-dim); font-size: 13px; }

/* Controls bar */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}

.controls-left { font-size: 13px; color: var(--text-dim); min-width: 120px; }
.controls-right { display: flex; gap: 8px; min-width: 120px; justify-content: flex-end; }

.controls-center {
  display: flex;
  gap: 10px;
  margin: 0 auto;
}

.ctrl-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.ctrl-btn:hover { background: #2a3342; }
.ctrl-btn.active-off { background: var(--danger); border-color: var(--danger); }
.ctrl-btn.active-off:hover { background: var(--danger-hover); }
.ctrl-btn.active-on { background: var(--accent); border-color: var(--accent); }
.ctrl-btn.danger { background: var(--danger); border-color: var(--danger); }
.ctrl-btn.danger:hover { background: var(--danger-hover); }
.ctrl-btn.ghost { background: transparent; }

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #262e3b;
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 50;
}
.toast.hidden { display: none; }

@media (max-width: 720px) {
  .side-panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; }
  .controls-left { display: none; }
}
