:root {
  --bg: #0f1419;
  --panel: #1a2129;
  --panel-2: #232c36;
  --text: #e7ecf1;
  --muted: #8b98a5;
  --accent: #2d8cff;
  --danger: #e5484d;
  --ok: #30a46c;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.5em; margin: 10px 0 0; font-size: 14px; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; }

/* Lobby / prejoin */
.lobby { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.card {
  background: var(--panel); border-radius: var(--radius); padding: 32px;
  width: 100%; max-width: 400px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.logo { font-size: 40px; }
h1 { margin: 8px 0 4px; font-size: 24px; }
input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid #33404d;
  background: var(--panel-2); color: var(--text); font-size: 15px; margin: 16px 0 12px;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { margin: 0; }

.btn {
  display: inline-block; border: 0; border-radius: 10px; padding: 12px 18px;
  background: var(--panel-2); color: var(--text); font-size: 15px; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn.block { display: block; width: 100%; margin-top: 16px; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 22px 0 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #33404d; }

/* Call screen */
#call { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: var(--panel);
}
.topbar-right { display: flex; gap: 12px; align-items: center; }

.grid {
  flex: 1; display: grid; gap: 16px; padding: 24px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-content: center; max-width: 1000px; width: 100%; margin: 0 auto;
}
.tile {
  position: relative; background: var(--panel); border-radius: var(--radius);
  aspect-ratio: 4 / 3; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  border: 3px solid transparent; transition: border-color .12s;
}
.tile.speaking:not(.is-muted) { border-color: var(--ok); }
.avatar {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; font-weight: 600; color: #fff;
}
.tile .name { font-weight: 500; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .status { position: absolute; top: 10px; right: 12px; font-size: 18px; }
.tile .conn { position: absolute; bottom: 10px; font-size: 12px; color: var(--muted); }

.controls {
  display: flex; justify-content: center; gap: 16px; padding: 18px;
  background: var(--panel);
}
.ctrl {
  width: 56px; height: 56px; border-radius: 50%; border: 0; font-size: 22px;
  background: var(--panel-2); cursor: pointer;
}
.ctrl:hover { filter: brightness(1.2); }
.ctrl.off { background: var(--danger); }
.ctrl.danger { background: var(--danger); transform: rotate(135deg); }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: #000c; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 500px) {
  .grid { grid-template-columns: repeat(2, 1fr); padding: 14px; gap: 10px; }
  .avatar { width: 56px; height: 56px; font-size: 20px; }
}
