:root {
  --bg: #0f1115;
  --panel: #141827;
  --fg: #e8ecf1;
  --muted: #9aa3b2;
  --accent: #5ac8fa;
  --danger: #ff5f56;
  --ok: #3ddc97;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --glass: rgba(20, 24, 39, 0.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #151b2e 0%, #121629 100%);
  border-bottom: 1px solid #1f2640;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(120%) blur(8px);
}
.brand { font-weight: 700; letter-spacing: 0.2px; }
.room-link { display: flex; gap: 8px; align-items: center; }
.room-link input {
  width: 320px; max-width: 60vw;
  background: #0d1020; color: var(--fg);
  border: 1px solid #2a2f45; border-radius: 10px; padding: 10px 12px;
}
.room-link button { padding: 10px 12px; }

.wrap { padding: 16px; display: grid; gap: 16px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

button {
  cursor: pointer;
  border: 1px solid #2b3046;
  background: #171c2a;
  color: var(--fg);
  padding: 10px 12px;
  border-radius: 10px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, opacity .2s;
}
button:hover { background: #1a2136; border-color: #3a456a; }
button:active { transform: translateY(1px); }
button.primary { background: #1b2133; border-color: #334066; color: #d3e8ff; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

input[type="text"] { background: #0d1020; color: var(--fg); border: 1px solid #2a2f45; border-radius: 10px; padding: 10px 12px; }

.tiles, .screens { display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
/* Make screen shares larger by default */
.screens { grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); }

.tile, .screen { background: var(--panel); border: 1px solid #252b42; border-radius: 12px; padding: 8px; box-shadow: var(--shadow); }
.tile { position: relative; }
.tile .name { color: var(--muted); font-size: 12px; margin-top: 6px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }

video, audio { width: 100%; height: auto; background: #000; border-radius: 10px; display: block; }

/* Screen tile with overlay actions */
.screen { position: relative; overflow: hidden; }
.tile .actions, .screen .actions {
  position: absolute; right: 10px; top: 10px;
  display: flex; gap: 8px; align-items: center;
  background: rgba(8, 10, 18, 0.45);
  padding: 6px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  opacity: 0; transform: translateY(-6px);
  transition: opacity .2s ease, transform .2s ease;
}
.screen:hover .actions, .tile:hover .actions { opacity: 1; transform: translateY(0); }
.icon-btn { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15); color: #eaf2ff; padding: 6px 10px; border-radius: 999px; font-size: 13px; }
.icon-btn:hover { background: rgba(255,255,255,0.1); }
.icon-btn.danger { background: rgba(255, 95, 86, 0.12); border-color: rgba(255, 95, 86, 0.26); color: #ffd3cf; }

.actions .vol {
  -webkit-appearance: none; appearance: none;
  width: 120px; height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.15); outline: none; border: 1px solid rgba(255,255,255,0.12);
}
.actions .vol::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
.actions .vol::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }

.hint { color: var(--muted); }
.status { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Access gate overlay */
.gate {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  backdrop-filter: blur(8px) saturate(120%);
  background: rgba(5, 7, 12, 0.6);
}
.gate .panel {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid #252b42;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid; gap: 12px;
}
.gate .title { font-weight: 700; }
.gate .row { display: grid; gap: 8px; }
.gate .err { color: var(--danger); min-height: 1em; }
.gate .actions { display: flex; gap: 8px; justify-content: flex-end; }
