:root {
  --bg: #0d0b14;
  --bg2: #16131f;
  --card: #1c1828;
  --line: #2c2740;
  --text: #ece9f5;
  --dim: #9a93b3;
  --accent: #7d5cff;
  --accent2: #9f85ff;
  --danger: #e2445c;
  --ok: #2fbf71;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }
a { color: var(--accent2); }
button { font: inherit; cursor: pointer; }

/* ---------- landing ---------- */
.wrap {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
  background: radial-gradient(1000px 600px at 50% -10%, #241c3d 0%, var(--bg) 60%);
  overflow-y: auto;
}
.logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.logo-mark {
  width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(140deg, var(--accent), #4ad6ff);
  display: grid; place-items: center;
}
.logo-mark svg { width: 24px; height: 24px; }
.logo-text { font-size: 22px; font-weight: 650; letter-spacing: -0.3px; }
h1 { font-size: clamp(30px, 6vw, 46px); line-height: 1.1; margin: 0 0 14px; letter-spacing: -1px; font-weight: 680; }
.sub { color: var(--dim); font-size: 17px; margin: 0 0 34px; max-width: 460px; }
.btn {
  border: 0; border-radius: 14px; padding: 15px 26px; font-size: 17px; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  box-shadow: 0 10px 30px rgba(125, 92, 255, 0.35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 36px rgba(125,92,255,.45); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.btn-ghost {
  background: var(--card); color: var(--text); border: 1px solid var(--line); box-shadow: none;
}
.btn-ghost:hover { background: #221d33; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; max-width: 520px; width: 100%; text-align: left;
}
.card h2 { margin: 0 0 6px; font-size: 19px; }
.card p { color: var(--dim); margin: 0 0 16px; font-size: 14px; }
.linkrow { display: flex; gap: 8px; }
.linkrow input {
  flex: 1; min-width: 0; background: #120f1c; border: 1px solid var(--line); color: var(--text);
  border-radius: 11px; padding: 13px 14px; font-size: 15px;
}
.hint { color: var(--dim); font-size: 13px; margin-top: 14px; }
.switch {
  display: inline-flex; align-items: center; gap: 9px; margin-top: 18px;
  color: var(--dim); font-size: 14px; cursor: pointer; user-select: none;
}
.switch input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.switch:hover { color: var(--text); }
.codefield {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 2px; text-transform: lowercase;
}
.foot { margin-top: 30px; color: #6c6485; font-size: 13px; }

/* ---------- lobby ---------- */
.lobby {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  gap: 36px; padding: 24px; flex-wrap: wrap;
  background: radial-gradient(1000px 600px at 50% -10%, #241c3d 0%, var(--bg) 60%);
  overflow-y: auto;
}
.preview {
  width: min(520px, 92vw); aspect-ratio: 4/3; background: #000; border-radius: 18px;
  overflow: hidden; position: relative; border: 1px solid var(--line);
}
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview .off {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim);
  background: #0a0812; font-size: 15px;
}
.join-box { width: min(360px, 92vw); text-align: left; }
.join-box h2 { margin: 0 0 8px; font-size: 26px; letter-spacing: -0.5px; }
.join-box p { color: var(--dim); margin: 0 0 20px; font-size: 15px; }
.field { width: 100%; background: #120f1c; border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 14px 15px; font-size: 16px; margin-bottom: 14px; }
.field:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.prejoin-ctl { display: flex; gap: 10px; margin-bottom: 18px; }
.err { color: #ff9aa6; font-size: 13px; margin-bottom: 12px; }

/* ---------- call ---------- */
.call { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--bg2); flex: 0 0 auto;
}
.topbar .name { font-weight: 600; font-size: 15px; }
.topbar .who { color: var(--dim); font-size: 13px; }
.spacer { flex: 1; }
.chip {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font-size: 13px;
}
.stage { flex: 1; display: flex; min-height: 0; }
.grid {
  flex: 1; display: grid; gap: 10px; padding: 12px; min-height: 0; min-width: 0;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}
.tile {
  position: relative; background: #000; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--line); min-height: 0; min-width: 0;
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.tile.me video:not(.screen) { transform: scaleX(-1); }
.tile .label {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px;
  background: rgba(10,8,18,.72); backdrop-filter: blur(6px);
  padding: 5px 10px; border-radius: 9px; font-size: 13px; max-width: calc(100% - 20px);
}
.tile .label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .avatar {
  position: absolute; inset: 0; display: none; place-items: center; background: #15111f;
}
.tile.camoff .avatar { display: grid; }
.tile.camoff video { visibility: hidden; }
.initials {
  width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #4ad6ff); font-size: 32px; font-weight: 650; color: #fff;
}
.tile .status { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
.badge {
  background: rgba(10,8,18,.72); border-radius: 8px; padding: 5px 7px; display: grid; place-items: center;
}
.badge.red { background: rgba(226,68,92,.9); }
.badge.green { background: rgba(47,191,113,.9); }
.tile.rejected { border-color: var(--danger); }
.tile.rejected .connecting { color: #ff9aa6; background: #1a0d12; }
.badge svg { width: 15px; height: 15px; display: block; }
.connecting {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); font-size: 13px;
  background: #0a0812;
}
.bar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px; border-top: 1px solid var(--line); background: var(--bg2); flex-wrap: wrap;
}
.ctl {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--text); display: grid; place-items: center;
  transition: background .12s;
}
.ctl:hover { background: #262038; }
.ctl svg { width: 22px; height: 22px; }
.ctl.on { background: #fff; color: #15111f; border-color: #fff; }
.ctl.off { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctl.hangup { width: auto; padding: 0 22px; border-radius: 26px; background: var(--danger); border-color: var(--danger); color: #fff; }
.ctl.hangup:hover { background: #c9394f; }
.panel {
  width: 320px; max-width: 100%; border-left: 1px solid var(--line); background: var(--bg2);
  display: none; flex-direction: column; flex: 0 0 auto;
}
.panel.open { display: flex; }
.panel h3 { margin: 0; padding: 14px; border-bottom: 1px solid var(--line); font-size: 15px; }
.msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { font-size: 14px; }
.msg b { color: var(--accent2); font-weight: 600; }
.msg div { color: var(--text); word-wrap: break-word; }
.chatform { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chatform input { flex: 1; min-width: 0; background: #120f1c; border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 11px 12px; font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: #2a2340; border: 1px solid var(--line); padding: 11px 18px; border-radius: 12px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50;
}
.toast.show { opacity: 1; }
@media (max-width: 760px) {
  .grid { grid-template-columns: repeat(var(--cols-sm, 1), minmax(0, 1fr)); padding: 8px; gap: 8px; }
  .panel { position: fixed; inset: 0; width: 100%; z-index: 40; border-left: 0; }
  .topbar .who { display: none; }
}
