:root {
  --bg: #0b0d12;
  --bg-elev: #141821;
  --bg-elev-2: #1c2230;
  --border: #2a3142;
  --text: #e7ecf3;
  --text-dim: #8a93a6;
  --accent: #4f8cff;
  --accent-hover: #3a78f0;
  --danger: #ff5252;
  --success: #34c759;
  --warning: #ffb020;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
body { padding-env: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 16px) 16px max(env(safe-area-inset-bottom), 16px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 16px;
}
.topbar h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.topbar .sub { color: var(--text-dim); font-size: 13px; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
}

label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 14px 14px;
  font-size: 16px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-height: 48px;
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: var(--accent-hover); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.danger { background: var(--danger); }
button.danger:hover { background: #e53e3e; }
button.ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
button.ghost:hover { background: var(--bg-elev-2); color: var(--text); }

.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.error {
  background: rgba(255, 82, 82, 0.12);
  border: 1px solid rgba(255, 82, 82, 0.3);
  color: #ff8a8a;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}
.error:empty { display: none; }

.status-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim);
  padding: 8px 12px;
  background: var(--bg-elev-2);
  border-radius: 8px;
  margin-bottom: 12px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.18); }
.dot.warn { background: var(--warning); }
.dot.err { background: var(--danger); }

.player-list { display: flex; flex-direction: column; gap: 8px; }
.player {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.player:hover { background: var(--bg-elev-2); border-color: #384156; }
.player:active { background: #232a3a; }
.player .avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f8cff, #6e6cff);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  flex-shrink: 0;
  color: white;
}
.player .info { flex: 1; min-width: 0; }
.player .name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.player .id-badge {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg-elev-2);
  border-radius: 6px;
  color: var(--text-dim);
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
}
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.modal p { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin: 0 0 16px; }

.call-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  padding: 40px 20px;
  text-align: center;
}
.call-avatar {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f8cff, #6e6cff);
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 700;
  color: white;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(79, 140, 255, 0.3);
}
.call-avatar.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(79, 140, 255, 0.3); }
  50% { box-shadow: 0 8px 32px rgba(79, 140, 255, 0.6); }
}
.call-name { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.call-status { color: var(--text-dim); font-size: 14px; margin-bottom: 4px; }
.call-timer { font-family: ui-monospace, "SF Mono", monospace; color: var(--text-dim); font-size: 14px; }

.call-controls { width: 100%; display: flex; flex-direction: column; gap: 10px; }

.vu-meter {
  display: flex; gap: 3px; align-items: center; height: 24px; margin: 20px 0;
}
.vu-bar {
  width: 4px; height: 100%;
  background: var(--bg-elev-2);
  border-radius: 2px;
  transition: background 0.05s;
}
.vu-bar.on { background: var(--success); }

.fab-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  min-height: 0;
  border-radius: 8px;
}

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
