:root {
  --bg: #070b17;
  --bg-2: #0d1428;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #e9edf8;
  --muted: #8d99b8;
  --accent: #6366f1;
  --accent-2: #22d3ee;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 600px at 12% -10%, rgba(99, 102, 241, 0.22), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(34, 211, 238, 0.16), transparent 55%),
    radial-gradient(700px 500px at 50% 110%, rgba(168, 85, 247, 0.12), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#app { position: relative; z-index: 1; min-height: 100%; }

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 14.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: transform .12s ease, background .18s ease, box-shadow .18s ease, opacity .18s;
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 10px 26px rgba(99, 102, 241, .35);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.secondary { background: linear-gradient(135deg, #0ea5e9, var(--accent-2)); }
.btn.ghost { background: rgba(255, 255, 255, .06); border-color: var(--card-border); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.btn.success { background: linear-gradient(135deg, #22c55e, #16a34a); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.round {
  width: 52px; height: 52px; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .10);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
}
.btn.round:hover { background: rgba(255, 255, 255, .17); }
.btn.round.danger { background: linear-gradient(135deg, #ef4444, #b91c1c); border-color: transparent; }
.btn.round.success { background: linear-gradient(135deg, #22c55e, #15803d); border-color: transparent; }
.btn.round.active { background: #fff; color: #111827; }

/* --------------------------------------------------------------- brand -- */
.brand { text-align: center; }
.brand-logo {
  width: 56px; height: 56px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 30px rgba(99, 102, 241, .4);
  color: #fff;
}
.brand-logo.sm { width: 32px; height: 32px; border-radius: 10px; margin: 0; }
.brand h1 { margin: 0; font-size: 27px; letter-spacing: -.4px; }
.brand.inline { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.2px; }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- auth -- */
.auth-wrap { display: grid; place-items: center; padding: 28px 18px; }
.auth-card {
  width: 100%; max-width: 430px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 32px 28px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: rgba(0, 0, 0, .28);
  padding: 5px; border-radius: 13px; margin: 24px 0 22px;
}
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 10px; border-radius: 9px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: .18s;
}
.tab.active { background: rgba(255, 255, 255, .10); color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field > span em { font-style: normal; font-weight: 400; opacity: .75; }
.field small { color: var(--muted); font-size: 11.5px; }
.field.checkbox { flex-direction: row; align-items: center; gap: 10px; }
.field.checkbox input { width: 17px; height: 17px; accent-color: var(--accent); }

input[type=text], input[type=password], .select {
  width: 100%;
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--card-border);
  border-radius: 11px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input[type=text]:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
input::placeholder { color: #5d688a; }
.select { appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238d99b8' stroke-width='2'><path d='M4 6l4 4 4-4'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap.grow { flex: 1 1 auto; }
.input-wrap.grow input { width: 100%; }
.username-status {
  position: absolute; right: 12px; font-size: 12px; font-weight: 600;
  pointer-events: none; white-space: nowrap;
}
.username-status.ok { color: var(--success); }
.username-status.bad { color: var(--danger); }

.auth-error {
  margin: 14px 0 0; color: #fca5a5; font-size: 13.5px; min-height: 18px;
  text-align: center; font-weight: 500;
}
.auth-hint { margin: 16px 0 0; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.55; }

/* ------------------------------------------------------------- topbar -- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 22px;
  border-bottom: 1px solid var(--card-border);
  background: rgba(7, 11, 23, .6);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 30;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.me-chip { display: flex; align-items: center; gap: 10px; }
.me-text { display: flex; flex-direction: column; line-height: 1.25; }
.me-text strong { font-size: 13.5px; }
.me-text small { color: var(--muted); font-size: 11.5px; }

.avatar {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: grid; place-items: center;
  border-radius: 50%; font-weight: 700; font-size: 14px;
  background: var(--accent); color: #fff;
  text-transform: uppercase;
}
.avatar.lg { width: 68px; height: 68px; flex-basis: 68px; font-size: 26px; }
.avatar.xl { width: 96px; height: 96px; flex-basis: 96px; font-size: 34px; }

/* --------------------------------------------------------------- home -- */
.home-grid {
  max-width: 1080px; margin: 0 auto; padding: 22px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
}
.card.span-2 { grid-column: span 2; }
.card h2 {
  margin: 0 0 16px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .9px; color: var(--muted);
  display: flex; align-items: center; gap: 9px;
}
.pill {
  background: rgba(255, 255, 255, .1); border-radius: 20px;
  padding: 2px 9px; font-size: 11px; letter-spacing: 0; color: var(--text);
}
.row-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-form .select { width: auto; min-width: 130px; }
.divider { text-align: center; margin: 14px 0; position: relative; color: var(--muted); font-size: 12px; }
.divider::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; background: var(--card-border);
}
.divider span { position: relative; padding: 0 12px; background: #0d1428; }
.hint { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }

.people-list, .history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.people-item, .history-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid transparent;
}
.people-item:hover { border-color: var(--card-border); }
.person-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.person-text strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-text small { color: var(--muted); font-size: 11.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: 0 0 8px; }
.dot.busy { background: var(--warn); }
.dot.offline { background: #46506e; }
.empty { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.hist-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.07); font-size: 15px; }
.hist-meta { flex: 1; min-width: 0; }
.hist-meta strong { display: block; font-size: 13.5px; }
.hist-meta small { color: var(--muted); font-size: 11.5px; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.permission-note {
  margin-top: 16px; padding: 11px 13px; border-radius: 11px;
  background: rgba(34, 211, 238, .09); border: 1px solid rgba(34, 211, 238, .22);
  font-size: 12.5px; color: #a5f3fc;
}

/* ----------------------------------------------------------- incoming -- */
.overlay {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: rgba(4, 7, 15, .78);
  backdrop-filter: blur(16px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.incoming-card { text-align: center; animation: pop .28s cubic-bezier(.2,1.3,.5,1); }
@keyframes pop { from { transform: scale(.86); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.pulse { position: relative; display: inline-block; margin-bottom: 16px; }
.pulse::before, .pulse::after {
  content: ""; position: absolute; inset: -12px; border-radius: 50%;
  border: 2px solid rgba(34, 197, 94, .55); animation: ring 1.8s ease-out infinite;
}
.pulse::after { animation-delay: .9s; }
@keyframes ring {
  0% { transform: scale(.85); opacity: .9 }
  100% { transform: scale(1.55); opacity: 0 }
}
.incoming-label { margin: 0; color: var(--success); font-size: 12.5px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; }
.incoming-card h3 { margin: 8px 0 4px; font-size: 25px; }
.incoming-sub { margin: 0 0 26px; color: var(--muted); font-size: 14px; }
.incoming-actions { display: flex; gap: 22px; justify-content: center; }
.incoming-actions .btn { width: 62px; height: 62px; }
.incoming-actions .btn.danger { animation: shake .55s ease-in-out infinite; }
@keyframes shake {
  0%,100% { transform: rotate(0) }
  25% { transform: rotate(-11deg) }
  75% { transform: rotate(11deg) }
}

/* --------------------------------------------------------------- call -- */
#call-screen { display: flex; flex-direction: column; background: #05070f; }
.call-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.remote-holder { position: absolute; inset: 0; background: #05070f; display: grid; place-items: center; }
.remote-holder video {
  width: 100%; height: 100%; object-fit: cover;
  background: #05070f; display: block;
}
.remote-placeholder { position: absolute; inset: 0; display: grid; place-items: center; gap: 14px; align-content: center; }
.remote-placeholder p { margin: 0; color: var(--muted); font-size: 14px; }
.remote-placeholder.hidden { display: none; }
.stage-badge {
  position: absolute; top: 18px; left: 18px;
  background: rgba(0, 0, 0, .5); backdrop-filter: blur(8px);
  padding: 6px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--card-border);
}
.local-holder {
  position: absolute; right: 18px; bottom: 18px; width: 190px; aspect-ratio: 3/4;
  border-radius: 14px; overflow: hidden; background: #0c1224;
  border: 1px solid rgba(255, 255, 255, .16); box-shadow: var(--shadow);
}
.local-holder video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.local-tag {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(0, 0, 0, .55); padding: 3px 8px; border-radius: 7px;
  font-size: 11px; font-weight: 600;
}
.call-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; background: rgba(10, 14, 28, .92);
  border-top: 1px solid var(--card-border);
}
.call-meta { display: flex; align-items: center; gap: 12px; font-size: 14px; min-width: 0; }
.call-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#call-timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.net-pill {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  background: rgba(34, 197, 94, .16); color: #86efac; border: 1px solid rgba(34, 197, 94, .3);
}
.net-pill.mid { background: rgba(245, 158, 11, .16); color: #fcd34d; border-color: rgba(245, 158, 11, .3); }
.net-pill.bad { background: rgba(239, 68, 68, .16); color: #fca5a5; border-color: rgba(239, 68, 68, .3); }
.call-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* live audio level meters (mic + incoming) */
.levels { display: flex; flex-direction: column; gap: 5px; min-width: 128px; }
.level-row { display: flex; align-items: center; gap: 7px; }
.lvl-tag { font-size: 9.5px; font-weight: 700; letter-spacing: .8px; color: var(--muted); width: 22px; }
.lvl-track {
  flex: 1; height: 5px; border-radius: 4px; background: rgba(255, 255, 255, .09);
  overflow: hidden;
}
.lvl-fill {
  height: 100%; width: 0%; border-radius: 4px;
  background: linear-gradient(90deg, #22c55e, #84cc16);
  transition: width .12s linear;
}
.lvl-fill.hot { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.stats-panel {
  position: fixed; right: 18px; top: 78px; z-index: 60;
  background: rgba(8, 12, 24, .93); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 14px 16px; min-width: 230px;
  backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.stats-panel h4 { margin: 0 0 9px; font-size: 12px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); }
.stat-row { display: flex; justify-content: space-between; gap: 16px; font-size: 12.5px; padding: 3px 0; }
.stat-row span { color: var(--muted); }
.stat-row b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- toast -- */
.toast-wrap {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 9px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(16, 22, 40, .96); border: 1px solid var(--card-border);
  color: var(--text); padding: 11px 17px; border-radius: 12px;
  font-size: 13.5px; box-shadow: var(--shadow);
  animation: toastIn .25s ease; max-width: 90vw;
}
.toast.error { border-color: rgba(239, 68, 68, .45); color: #fecaca; }
.toast.success { border-color: rgba(34, 197, 94, .45); color: #bbf7d0; }
@keyframes toastIn { from { transform: translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ----------------------------------------------------------- responsive */
@media (max-width: 760px) {
  .home-grid { grid-template-columns: 1fr; padding: 14px; }
  .card.span-2 { grid-column: span 1; }
  .local-holder { width: 116px; right: 12px; bottom: 12px; }
  .call-bar { flex-direction: column; align-items: stretch; gap: 12px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .call-actions { justify-content: center; }
  .call-meta { justify-content: center; }
  .brand-name { display: none; }
}
