:root {
  color-scheme: light dark;
  --bg: #f6f7fb;
  --fg: #1a1a1f;
  --muted: #6b6f7a;
  --card: #ffffff;
  --border: #e3e5ec;
  --accent: #4A90D9;
  --accent-fg: #ffffff;
  --error: #d94a4a;
  --shadow: 0 2px 12px rgba(20,20,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151a;
    --fg: #ececf0;
    --muted: #9a9eac;
    --card: #1e1f26;
    --border: #2a2c35;
    --shadow: 0 2px 16px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}
#app { min-height: 100dvh; padding: max(env(safe-area-inset-top), 16px) 16px max(env(safe-area-inset-bottom), 16px); }
.view { max-width: 900px; margin: 0 auto; }
.hidden { display: none !important; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 40vh auto 0;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
#login-view { padding-top: 10vh; }
#login-view h1 { font-size: 28px; margin: 0 0 24px; text-align: center; }
#login-form { display: flex; flex-direction: column; gap: 14px; max-width: 380px; margin: 0 auto; }
#login-form label { display: flex; flex-direction: column; gap: 6px; }
#login-form span { color: var(--muted); font-size: 14px; }
#login-form input {
  font-size: 18px; padding: 14px 16px;
  background: var(--card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 12px;
  outline: none;
}
#login-form input:focus { border-color: var(--accent); }
button {
  font-size: 17px; font-weight: 600;
  padding: 14px 18px; border-radius: 12px;
  border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-fg);
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost {
  background: transparent; color: var(--muted); font-weight: 500;
  padding: 8px 12px; font-size: 14px;
}
.error { color: var(--error); margin: 4px 0 0; min-height: 1.2em; text-align: center; }

/* Main */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.chip { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.chip .avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; }
#greeting { font-size: 22px; margin: 4px 0 22px; }
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.user-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 14px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.user-card .avatar-big {
  width: 86px; height: 86px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 46px; line-height: 1;
}
.user-card .name { font-weight: 600; font-size: 17px; text-align: center; }
.user-card .status { font-size: 12px; color: var(--muted); }
.user-card .status.online { color: #4caf50; }
.user-card .status.online::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  background: #4caf50; border-radius: 50%; margin-right: 6px; vertical-align: 1px;
}
.user-card .call-btn {
  width: 100%; padding: 12px;
  background: var(--accent); color: var(--accent-fg);
  border-radius: 12px; font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.user-card .call-btn:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 1;
}

.group-call {
  margin-top: 22px; width: 100%; max-width: 380px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: transparent; color: var(--fg);
  border: 2px dashed var(--border);
}
@media (min-width: 600px) {
  .group-call { margin: 22px auto 0; }
}
