:root {
  --bg: #0b0c0f;
  --bg-soft: #14161b;
  --surface: #1a1d24;
  --line: #262a33;
  --text: #f2f4f8;
  --muted: #8b919e;
  --accent: #6ee7b7;
  --accent-soft: rgba(110, 231, 183, 0.14);
  --danger: #f87171;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: radial-gradient(1200px 800px at 50% -10%, #15181f 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 24px; }

.app { width: 100%; max-width: 440px; }

.hidden { display: none !important; }

/* ---------- Lobby ---------- */
.brand { text-align: center; margin-bottom: 36px; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); display: inline-block; margin-right: 8px;
  box-shadow: 0 0 16px var(--accent);
}
.brand h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.brand p { color: var(--muted); font-size: 14px; margin-top: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.field input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  padding: 14px 16px;
  font-family: var(--font);
  transition: border-color .15s ease;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input::placeholder { color: #565c68; }

.btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 15px 16px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform .08s ease, opacity .15s ease, background .15s ease;
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--accent); color: #06281c; }
.btn-primary:hover { opacity: .92; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.row { display: flex; gap: 10px; }
.row .btn { width: auto; flex: 1; }

.hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; line-height: 1.5; }

/* ---------- Call ---------- */
.call-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.call-head .room { display: flex; flex-direction: column; }
.call-head .room .label { font-size: 12px; color: var(--muted); }
.call-head .room .name { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.copy {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  border-radius: 10px; padding: 9px 12px; font-size: 13px; cursor: pointer; font-family: var(--font);
  display: flex; align-items: center; gap: 6px; transition: all .15s ease;
}
.copy:hover { color: var(--text); border-color: var(--accent); }
.copy.copied { color: var(--accent); border-color: var(--accent); }

.peers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 18px 10px;
  margin-bottom: 36px;
  min-height: 120px;
}
.peer { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.avatar-wrap { position: relative; width: 72px; height: 72px; }
.avatar {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 600; color: var(--text);
  background: linear-gradient(160deg, #2a2e38, #1a1d24);
  border: 1px solid var(--line);
  position: relative; z-index: 2;
}
.ring {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0; transform: scale(0.92);
  transition: opacity .12s ease, transform .12s ease;
  z-index: 1;
}
.peer.speaking .ring { opacity: 1; }
.peer.muted .avatar { opacity: .55; }
.peer .pname { font-size: 13px; color: var(--muted); max-width: 90px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer.self .pname { color: var(--text); }
.badge-mute {
  position: absolute; right: -2px; bottom: -2px; z-index: 3;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  display: none; align-items: center; justify-content: center; font-size: 12px;
}
.peer.muted .badge-mute { display: flex; }

.controls { display: flex; align-items: center; justify-content: center; gap: 16px; }
.ctrl {
  width: 60px; height: 60px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s ease;
}
.ctrl:active { transform: scale(0.94); }
.ctrl.mic-off { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ctrl.leave { background: rgba(248,113,113,0.12); border-color: var(--danger); color: var(--danger); }
.ctrl.leave:hover { background: var(--danger); color: #2a0a0a; }

.status { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; height: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0;
  transition: all .25s ease; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Home ---------- */
.home-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.me { display: flex; flex-direction: column; }
.me-label { font-size: 12px; color: var(--muted); }
.me-nick { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.link-btn { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; font-family: var(--font); text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }

.block { margin-bottom: 22px; }
.block-title { font-size: 13px; color: var(--muted); margin-bottom: 12px; font-weight: 500; }
.muted-sm { color: #565c68; font-size: 11px; }

.callrow { display: flex; gap: 10px; }
.callrow input {
  flex: 1; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 16px; padding: 13px 15px; font-family: var(--font);
}
.callrow input:focus { outline: none; border-color: var(--accent); }
.callrow input::placeholder { color: #565c68; }
.btn-inline { width: auto; flex: 0 0 auto; padding: 13px 18px; }

.online-list, .room-list { display: flex; flex-direction: column; gap: 8px; }
.empty { color: #565c68; font-size: 14px; padding: 6px 2px; }

.contact, .room-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px;
}
.c-left { display: flex; align-items: center; gap: 12px; }
.c-av { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; background: linear-gradient(160deg, #2a2e38, #1a1d24); border: 1px solid var(--line); }
.c-name { font-size: 16px; font-weight: 500; }
.c-call, .r-join {
  background: var(--accent); color: #06281c; border: none; border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--font);
}
.c-call:active, .r-join:active { transform: scale(0.96); }
.r-left { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 500; cursor: pointer; }
.r-join { background: transparent; color: var(--accent); border: 1px solid var(--line); }

/* ---------- Video tiles ---------- */
.pvideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; z-index: 2; background: #000; }
.peer.has-video .ring { inset: -4px; }

/* ---------- Control button states ---------- */
.ctrl.cam-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ctrl.spk-off { background: var(--bg-soft); color: var(--muted); }

/* ---------- Call overlays (incoming/outgoing) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(800px 600px at 50% 20%, #16191f 0%, #07080a 70%);
  display: flex; align-items: center; justify-content: center; padding: 32px;
}
.ov-card { display: flex; flex-direction: column; align-items: center; text-align: center; }
.ov-pulse { position: relative; width: 132px; height: 132px; display: flex; align-items: center; justify-content: center; margin-bottom: 26px; }
.ov-pulse::before, .ov-pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent);
  animation: ovring 2s ease-out infinite; opacity: 0;
}
.ov-pulse::after { animation-delay: 1s; }
@keyframes ovring { 0% { transform: scale(0.7); opacity: 0.7; } 100% { transform: scale(1.35); opacity: 0; } }
.ov-avatar {
  width: 104px; height: 104px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 600; color: var(--text);
  background: linear-gradient(160deg, #2a2e38, #14161b); border: 1px solid var(--line); position: relative; z-index: 2;
}
.ov-name { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.ov-sub { color: var(--muted); font-size: 15px; margin-top: 8px; }
.ov-actions { display: flex; gap: 40px; margin-top: 52px; }
.ov-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer; font-family: var(--font);
}
.ov-btn .ic {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  transition: transform .08s ease, filter .15s ease;
}
.ov-btn:active .ic { transform: scale(0.92); }
.ov-btn .lb { font-size: 13px; color: var(--muted); }
.ov-btn.accept .ic { background: var(--accent); color: #06281c; box-shadow: 0 8px 24px rgba(110,231,183,0.3); }
.ov-btn.decline .ic { background: var(--danger); color: #2a0a0a; box-shadow: 0 8px 24px rgba(248,113,113,0.25); }
