:root {
  --bg: #0b0b12;
  --surface: #14141e;
  --surface-2: #1b1b28;
  --surface-3: #232334;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ededf5;
  --muted: #8b8ba3;
  --accent: #6366f1;
  --accent-2: #a855f7;
  --danger: #ef4444;
  --ok: #10b981;
  --radius: 14px;
  --shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1000px 600px at 15% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(900px 500px at 85% 0%, rgba(168, 85, 247, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: rgba(11, 11, 18, 0.75);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.02em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 14px;
}

.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-2); border-color: var(--border); }

.account { display: flex; align-items: center; gap: 10px; }
.whoami { color: var(--muted); font-size: 13px; }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 11px;
  font-weight: 650;
}

/* ---------- layout ---------- */
main { padding: 28px 24px 60px; max-width: 1180px; margin: 0 auto; }
.hidden { display: none !important; }

.chat-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 20px; }
.inbox-grid { display: grid; grid-template-columns: 330px 1fr; gap: 20px; }
@media (max-width: 900px) {
  .chat-grid, .inbox-grid { grid-template-columns: 1fr; }
  main { padding: 20px 16px 48px; }
}

.panel {
  background: linear-gradient(180deg, var(--surface), rgba(20, 20, 30, 0.7));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.panel-head { margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.panel-sub { color: var(--muted); font-size: 13px; }

/* ---------- call panel ---------- */
.call-panel { align-items: center; text-align: center; }
.call-visual { margin: 18px 0 22px; }

.orb {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px var(--border-strong), 0 20px 60px -15px rgba(99, 102, 241, 0.7);
  font-size: 40px;
  transition: transform .3s;
}
.orb.searching { animation: pulse 1.8s ease-in-out infinite; }
.orb.live { animation: pulse 2.4s ease-in-out infinite; box-shadow: 0 0 0 1px var(--border-strong), 0 20px 60px -12px rgba(16,185,129,.65); background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.2), transparent 55%), linear-gradient(135deg, #10b981, #06b6d4); }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: .95; }
  50% { transform: scale(1.06); opacity: 1; }
}

.status { font-size: 19px; font-weight: 550; letter-spacing: -0.01em; }
.timer { color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 6px; }
.diag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 8px;
  word-break: break-word;
  min-height: 16px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: auto;
  padding-top: 22px;
}
.hint { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-weight: 550;
  border-radius: 11px;
  padding: 10px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s, filter .15s, background .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 28px -10px rgba(99, 102, 241, 0.85);
}
.btn-secondary { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }

.link {
  background: none;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  font: inherit;
  font-weight: 550;
  padding: 0;
}

/* ---------- messages ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding-right: 4px;
}
.msg {
  max-width: 78%;
  padding: 9px 14px;
  border-radius: 14px;
  background: var(--surface-3);
  word-wrap: break-word;
  animation: rise .18s ease-out;
}
.msg.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }

.composer { display: flex; gap: 9px; }
.composer input {
  flex: 1;
  padding: 12px 15px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s;
}
.composer input:focus { border-color: var(--accent); }

/* ---------- lists ---------- */
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 13px 15px;
  border-radius: 12px;
}
.row .who { font-weight: 550; }
.row .meta { color: var(--muted); font-size: 12.5px; }
.row-actions { display: flex; gap: 7px; }
.clickable { cursor: pointer; transition: background .15s; }
.clickable:hover { background: var(--surface-3); }
.empty { color: var(--muted); padding: 10px 2px; }

/* ---------- gates ---------- */
.gate { text-align: center; padding: 40px 24px; }
.gate h3 { margin: 0 0 8px; font-size: 18px; letter-spacing: -0.01em; }
.gate p { color: var(--muted); max-width: 420px; margin: 0 auto 20px; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 5, 10, 0.72);
  backdrop-filter: blur(6px);
  z-index: 50;
  padding: 20px;
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 30px;
  box-shadow: var(--shadow);
  animation: rise .2s ease-out;
}
.modal-card h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -0.02em; }
.modal-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-form input {
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
}
.auth-switch { text-align: center; color: var(--muted); font-size: 13.5px; margin: 18px 0 0; }
