:root {
  --bg: #0f1c17;
  --bg2: #163028;
  --panel: rgba(26, 58, 47, 0.88);
  --ink: #f2f7f4;
  --muted: #a8c0b4;
  --accent: #3ecf8e;
  --line: rgba(255,255,255,.1);
  --danger: #ff6b6b;
  --me: #1f6b4a;
  --them: rgba(255,255,255,.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 0% 0%, #1f4d3a 0%, transparent 55%),
    linear-gradient(165deg, var(--bg), var(--bg2));
}

#app { height: 100%; max-width: 560px; margin: 0 auto; position: relative; }
.screen { height: 100%; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

.login-card {
  margin: auto 18px;
  padding: 28px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(10px);
}
.eyebrow { color: var(--accent); font-weight: 600; font-size: .85rem; margin: 0 0 8px; }
.login-card h1, .top h2, #call-name {
  font-family: Manrope, sans-serif;
  font-weight: 800;
  letter-spacing: -.03em;
  margin: 0 0 8px;
}
.login-card h1 { font-size: 2rem; }
.sub, .hint, .who { color: var(--muted); margin: 0 0 18px; }
.hint { margin-top: 14px; font-size: .9rem; }
label { display: block; font-size: .9rem; color: var(--muted); margin: 12px 0 8px; }
input[type="password"], input[type="text"], #msg-input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.28);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 14px;
  font-size: 1rem;
  outline: none;
}
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
.pill.active { background: var(--accent); color: #062116; border-color: transparent; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-family: Manrope, sans-serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #062116; width: 100%; margin-top: 16px; }
.btn.secondary-link {
  display: block; text-align: center; text-decoration: none;
  margin-top: 10px; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.04);
  font-family: Manrope, sans-serif; font-weight: 700;
}
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: white; }
.btn.call, .btn.voice, .btn.send {
  width: 48px; min-width: 48px; height: 48px; border-radius: 14px; padding: 0;
  display: grid; place-items: center; font-size: 1.2rem;
}
.btn.call { background: rgba(62,207,142,.15); color: var(--accent); }
.btn.voice { background: rgba(255,255,255,.06); color: var(--ink); }
.btn.send { background: var(--accent); color: #062116; width: auto; min-width: 48px; padding: 0 14px; margin: 0; }
.btn.round { width: 72px; height: 72px; border-radius: 50%; font-size: 1rem; }
.error { color: #ffb4a8; margin-top: 12px; }

.top {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.top .grow { flex: 1; min-width: 0; }
.top h2 { font-size: 1.25rem; }
.people {
  display: flex; gap: 10px; overflow-x: auto; padding: 14px 16px 6px;
}
.person {
  flex: 0 0 auto; width: 72px; text-align: center; cursor: pointer;
}
.avatar {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; margin: 0 auto 6px;
  font-weight: 800; font-family: Manrope, sans-serif; color: #062116;
  position: relative;
}
.avatar .dot {
  position: absolute; right: 2px; bottom: 2px; width: 10px; height: 10px;
  border-radius: 50%; background: #666; border: 2px solid var(--bg);
}
.avatar .dot.on { background: var(--accent); }
.person span { font-size: .78rem; color: var(--muted); }

.list { flex: 1; overflow: auto; padding: 8px 12px 20px; }
.room-item {
  display: flex; gap: 12px; align-items: center;
  padding: 12px; border-radius: 16px; cursor: pointer;
  border: 1px solid transparent;
}
.room-item:active, .room-item:hover { background: rgba(255,255,255,.04); border-color: var(--line); }
.room-item .meta { flex: 1; min-width: 0; }
.room-item b { display: block; font-family: Manrope, sans-serif; }
.room-item p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.messages {
  flex: 1; overflow: auto; padding: 14px 12px 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--them);
  align-self: flex-start;
}
.bubble.me { background: var(--me); align-self: flex-end; }
.bubble .name { font-size: .75rem; color: var(--accent); margin-bottom: 4px; font-weight: 600; }
.bubble.me .name { display: none; }
.bubble .time { display: block; margin-top: 6px; font-size: .7rem; color: rgba(255,255,255,.45); text-align: right; }
.bubble audio { width: min(220px, 70vw); margin-top: 4px; }
.bubble.call-note { opacity: .85; font-style: italic; }

.composer {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(0,0,0,.2);
}
.composer input { flex: 1; }

.rec-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(255, 80, 80, .12);
  border-top: 1px solid rgba(255,80,80,.25);
}
.rec-bar .btn.primary, .rec-bar .btn.ghost { width: auto; margin: 0; }
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #ff5a5a;
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: .3; } }

.call-screen {
  align-items: center; justify-content: center; text-align: center; gap: 10px;
  background: radial-gradient(circle at 50% 30%, #1f4d3a, #0b1411 70%);
}
.call-actions { margin-top: 40px; }

.incoming {
  position: absolute; left: 12px; right: 12px; top: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 16px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.35); z-index: 20;
}
.incoming .row { display: flex; gap: 10px; margin-top: 12px; }
.incoming .btn { flex: 1; margin: 0; }
