* { box-sizing: border-box; }

:root {
  --bg-1: #0b1020;
  --bg-2: #131a30;
  --surface: rgba(255,255,255,0.05);
  --surface-solid: #161d33;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text: #eef1fb;
  --text-dim: #93a0c2;
  --accent: #22d3a7;
  --accent-dim: #16997a;
  --accent-glow: rgba(34,211,167,0.45);
  --danger: #f55d6e;
  --danger-dim: #3a1620;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

html, body {
  margin: 0;
  min-height: 100vh;
}

body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(34,211,167,0.10), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(99,102,241,0.14), transparent 40%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  padding: 16px;
}

.hidden { display: none !important; }

/* ============ Join screen ============ */
.screen { width: 100%; max-width: 430px; }

.card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border-radius: var(--radius-lg);
  padding: 30px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  border: 1px solid var(--border-strong);
}

.brand { text-align: center; margin-bottom: 26px; }
.brand-icon {
  font-size: 34px;
  width: 64px; height: 64px;
  margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(34,211,167,0.22), rgba(34,211,167,0.05));
  border: 1px solid rgba(34,211,167,0.3);
}
.brand h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.3px; }
.brand-sub { margin: 6px 0 0; font-size: 12.5px; color: var(--text-dim); }

label {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 16px 0 7px;
  font-weight: 500;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #5b6788; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,167,0.15); }

.primary-btn {
  width: 100%;
  margin-top: 24px;
  padding: 15px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #04241c;
  font-weight: 800;
  font-size: 15.5px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(34,211,167,0.28);
  transition: transform .12s;
}
.primary-btn:active { transform: scale(0.97); }
.primary-btn:disabled { opacity: 0.6; cursor: default; }

.error {
  color: var(--danger);
  font-size: 12.5px;
  min-height: 18px;
  text-align: center;
  margin-top: 12px;
}

/* ============ Room screen ============ */
#roomScreen { max-width: 460px; width: 100%; }

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  backdrop-filter: blur(18px);
  padding: 13px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.room-chip {
  font-size: 13.5px;
  color: var(--text-dim);
  background: rgba(0,0,0,0.25);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.room-chip b { color: var(--text); font-weight: 700; }

.status { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.dot.red { background: var(--danger); box-shadow: 0 0 8px rgba(245,93,110,0.5); }

.speaking-banner {
  text-align: center;
  padding: 11px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-dim);
  font-weight: 500;
  transition: all 0.2s;
}
.speaking-banner.active {
  background: rgba(34,211,167,0.12);
  border-color: rgba(34,211,167,0.4);
  color: var(--accent);
  font-weight: 700;
}
.speaking-banner.busy {
  background: var(--danger-dim);
  border-color: rgba(245,93,110,0.4);
  color: var(--danger);
  font-weight: 700;
}

.ptt-wrap {
  display: flex;
  justify-content: center;
  padding: 14px 0 6px;
}

.ptt-btn {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 32% 28%, #24304f, #0e1327);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease;
  touch-action: none;
  box-shadow:
    0 0 0 1px var(--border-strong),
    0 14px 40px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
.ptt-btn .ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color .15s, box-shadow .15s;
}
.ptt-btn .mic { font-size: 46px; }
.ptt-btn .label { font-size: 14.5px; font-weight: 700; color: var(--text-dim); }

.ptt-btn.talking {
  transform: scale(1.04);
  background: radial-gradient(circle at 32% 28%, #1a4c3d, #06120e);
}
.ptt-btn.talking .ring {
  border-color: var(--accent);
  box-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(34,211,167,0.2);
}
.ptt-btn.talking .label { color: var(--accent); }

.mic-gain {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.mic-gain label { margin: 0 0 9px; }
.mic-gain input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.users {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
}
.users h3 { margin: 0 0 9px; font-size: 13px; color: var(--text-dim); font-weight: 700; }
#userList { list-style: none; margin: 0; padding: 0; }
#userList li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
}
#userList li:last-child { border-bottom: none; }

/* ============ Chat panel ============ */
.chat-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-panel h3 { margin: 0 2px; font-size: 13px; color: var(--text-dim); font-weight: 700; }

.chat-log {
  height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 4px 4px 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }

.chat-empty { text-align: center; color: #4a5578; font-size: 12.5px; margin: auto; }

.chat-msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  word-wrap: break-word;
  align-self: flex-start;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
}
.chat-msg.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(34,211,167,0.22), rgba(34,211,167,0.10));
  border-color: rgba(34,211,167,0.3);
}
.chat-msg .who {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  display: block;
}
.chat-msg.mine .who { color: #8be9d0; }
.chat-msg .txt { color: var(--text); }
.chat-msg .time {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
  display: block;
  text-align: left;
}
.chat-msg.voice-note .txt { display: flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; }

.chat-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
#chatInput {
  flex: 1;
  padding: 11px 14px;
  border-radius: 22px;
  border: 1px solid var(--border-strong);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
#chatInput:focus { border-color: var(--accent); }

.chat-send-btn, .chat-mic-btn {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, box-shadow .15s, background .15s;
}
.chat-send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #04241c;
  transform: rotate(180deg);
}
.chat-send-btn:active { transform: rotate(180deg) scale(0.9); }

.chat-mic-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  touch-action: none;
}
.chat-mic-btn.talking {
  background: radial-gradient(circle at 35% 30%, #1a4c3d, #06120e);
  color: var(--accent);
  box-shadow: 0 0 18px var(--accent-glow);
  border-color: var(--accent);
}

.leave-btn {
  padding: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245,93,110,0.35);
  background: var(--danger-dim);
  color: var(--danger);
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-solid); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 18px; border-radius: 20px; font-size: 13px; z-index: 999;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
}
