:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1f2630;
  --line: #2a323d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 600px at 10% -10%, #17202b 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.2px; }
.logo {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 9px var(--accent);
}
.muted { color: var(--muted); font-weight: 400; }
.status { display: flex; align-items: center; gap: 8px; }
.pill {
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font: 12px var(--mono);
}

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.connecting, .dot.new { background: var(--warn); }
.dot.connected, .dot.open { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.failed, .dot.closed, .dot.disconnected { background: var(--bad); }

main { flex: 1; min-height: 0; }

#lobby {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  align-content: center;
  gap: 20px;
  padding: 24px;
  overflow: auto;
}
.card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgb(0 0 0 / 35%);
}
.card h1 { margin: 0; font-size: 22px; }
.card h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 10px; }

.meetings ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.meeting {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.meeting .info { flex: 1; min-width: 0; }
.meeting .room { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meeting .who { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meeting .count { font: 12px var(--mono); color: var(--muted); }
.meeting button { padding: 6px 14px; font-size: 13px; }
.meeting.full { opacity: 0.6; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); flex: none; }
.card p { margin: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input:not([type="checkbox"]),
select {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
}
input:focus,
select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.error { color: var(--bad); font-size: 13px; }

button {
  padding: 10px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.6; cursor: wait; }
button.primary { background: var(--accent); border-color: var(--accent); color: #04130a; font-weight: 600; }
button.danger { background: var(--bad); border-color: var(--bad); color: #1a0505; font-weight: 600; }
button.off { background: transparent; color: var(--muted); text-decoration: line-through; }

#call { display: flex; flex-direction: column; }
#grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-content: center;
  gap: 14px;
  padding: 18px;
  overflow: auto;
}
.tile {
  position: relative;
  margin: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.local video { transform: scaleX(-1); }
.tile.local.pattern video { transform: none; }
.tile figcaption {
  position: absolute; left: 10px; bottom: 10px;
  display: flex; align-items: center; gap: 7px;
  padding: 4px 10px;
  background: rgb(14 17 22 / 70%);
  border-radius: 999px;
  font-size: 13px;
  backdrop-filter: blur(6px);
}
.tile .hud {
  position: absolute; right: 10px; top: 10px;
  padding: 4px 10px;
  background: rgb(14 17 22 / 70%);
  border-radius: 8px;
  font: 12px var(--mono);
  white-space: pre;
}

.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgb(22 27 34 / 80%);
}

#toast {
  position: fixed; left: 50%; bottom: 90px;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 40%);
  font-size: 14px;
}

@media (max-width: 560px) {
  #grid { grid-template-columns: 1fr; padding: 10px; }
  .controls button { padding: 9px 12px; }
}
