:root {
  --bg: #070b16;
  --bg-2: #0d1224;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-strong: rgba(255, 255, 255, 0.14);
  --border: rgba(255, 255, 255, 0.12);
  --text: #eff4ff;
  --muted: rgba(239, 244, 255, 0.62);
  --cyan: #67e8f9;
  --blue: #60a5fa;
  --violet: #a78bfa;
  --pink: #f472b6;
  --good: #34d399;
  --bad: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(96,165,250,0.13), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(244,114,182,0.14), transparent 32%),
    radial-gradient(circle at 20% 90%, rgba(167,139,250,0.15), transparent 30%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  overflow: hidden;
}

.hidden { display: none !important; }
.show { display: grid; }

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.38;
  animation: drift 12s ease-in-out infinite;
  pointer-events: none;
}
.orb-1 { width: 320px; height: 320px; background: rgba(103,232,249,0.23); top: -60px; left: -60px; }
.orb-2 { width: 280px; height: 280px; background: rgba(244,114,182,0.18); right: -40px; top: 120px; animation-delay: -3s; }
.orb-3 { width: 360px; height: 360px; background: rgba(167,139,250,0.18); bottom: -70px; left: 30%; animation-delay: -6s; }

@keyframes drift {
  0%, 100% { transform: translateY(0) translateX(0) scale(1); }
  50% { transform: translateY(18px) translateX(-10px) scale(1.06); }
}

.shell {
  width: min(1500px, calc(100vw - 28px));
  height: min(930px, calc(100vh - 28px));
  margin: 14px auto;
  position: relative;
}

.glass-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.auth-screen {
  grid-template-columns: 1.3fr 0.8fr;
  gap: 22px;
  height: 100%;
}

.auth-left, .auth-right {
  border-radius: 34px;
  padding: 34px;
}

.auth-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: var(--shadow);
}

.brand-pill, .brand-small {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.35em;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--cyan);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(103,232,249,0.10);
  border: 1px solid rgba(103,232,249,0.20);
  width: fit-content;
}

.auth-left h1 {
  margin: 18px 0 10px;
  font-size: clamp(38px, 5vw, 76px);
  line-height: 0.98;
  max-width: 10ch;
}

.auth-left p {
  margin: 0 0 24px;
  max-width: 580px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.feature-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  transform: translateY(0);
  transition: transform 0.22s ease, background 0.22s ease;
}
.feature-card:hover { transform: translateY(-4px); background: rgba(255,255,255,0.09); }
.feature-title { display: block; font-weight: 700; margin-bottom: 6px; }
.feature-text { color: var(--muted); font-size: 14px; }

.auth-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  background: rgba(255,255,255,0.04);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
}
.tab {
  flex: 1;
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: 14px 18px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.tab.active { background: rgba(255,255,255,0.10); color: var(--text); }
.tab:hover { transform: translateY(-1px); }

.form { display: none; gap: 14px; }
.form.active { display: grid; }
label span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
input, textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 18px;
  padding: 15px 16px;
  outline: none;
  transition: border 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
input:focus, textarea:focus {
  border-color: rgba(103,232,249,0.45);
  background: rgba(255,255,255,0.10);
}
input::placeholder, textarea::placeholder { color: rgba(239,244,255,0.35); }

button {
  font: inherit;
  color: inherit;
}
.primary-btn, .ghost-btn, .icon-btn {
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, filter 0.18s ease;
}
.primary-btn:hover, .ghost-btn:hover, .icon-btn:hover { transform: translateY(-2px); }
.primary-btn:active, .ghost-btn:active, .icon-btn:active { transform: translateY(0); }
.primary-btn:disabled, .ghost-btn:disabled, .icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.primary-btn {
  padding: 15px 18px;
  border-radius: 18px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  color: #03131d;
  box-shadow: 0 16px 44px rgba(96, 165, 250, 0.28);
}
.ghost-btn {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
}
.small-btn { padding: 10px 14px; border-radius: 14px; }
.icon-btn {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 20px;
}
.icon-btn.danger { background: rgba(251,113,133,0.12); }

.app-screen {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  height: 100%;
}
.sidebar, .chat-area {
  border-radius: 30px;
  overflow: hidden;
}
.sidebar {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sidebar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.me-label { margin-top: 8px; color: var(--muted); font-size: 14px; }
.network-card {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  border-radius: 22px;
  padding: 14px;
}
.network-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  color: var(--muted);
}
.network-row strong { color: var(--text); font-weight: 800; }

.search-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(239,244,255,0.45);
  margin: 8px 4px 8px;
}
.side-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.request-list {
  min-height: 60px;
  max-height: 156px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.request-item, .friend-item {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  padding: 12px;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.request-user { font-weight: 700; margin-bottom: 8px; }
.request-actions { display: flex; gap: 8px; }
.request-tag { color: var(--muted); font-size: 13px; }

.friends-title { margin-top: 4px; }
.friends-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  min-height: 0;
}
.friend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border 0.18s ease;
}
.friend-item:hover { transform: translateY(-2px); background: rgba(255,255,255,0.09); }
.friend-item.active { border-color: rgba(103,232,249,0.35); background: rgba(103,232,249,0.10); }
.friend-meta { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #07121c;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  flex-shrink: 0;
}
.friend-text { min-width: 0; }
.friend-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-status { color: var(--muted); font-size: 13px; margin-top: 4px; }
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
}
.status-dot.online { background: var(--good); box-shadow: 0 0 18px rgba(52,211,153,0.75); }

.chat-area {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  position: relative;
}
.chat-area::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(103,232,249,0.08), transparent 30%);
  pointer-events: none;
}
.chat-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.chat-title { font-size: 26px; font-weight: 900; }
.chat-subtitle { margin-top: 6px; color: var(--muted); }
.chat-actions { display: flex; gap: 10px; }

.call-banner, .typing-indicator {
  position: relative;
  z-index: 1;
  margin: 14px 18px 0;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(103,232,249,0.18);
  background: rgba(103,232,249,0.08);
}
.call-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.call-banner-actions { display: flex; gap: 10px; }
.typing-indicator {
  color: var(--muted);
  animation: pulseGlow 1.6s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(103,232,249,0.00); }
  50% { box-shadow: 0 0 20px rgba(103,232,249,0.12); }
}

.messages {
  position: relative;
  z-index: 1;
  overflow: auto;
  padding: 18px 24px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message-row {
  display: flex;
  animation: messageIn 0.22s ease;
}
.message-row.me { justify-content: flex-end; }
@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.message-bubble {
  max-width: min(72%, 780px);
  border-radius: 24px;
  padding: 14px 16px;
  line-height: 1.55;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.07);
  box-shadow: 0 10px 26px rgba(0,0,0,0.12);
}
.message-row.me .message-bubble {
  background: linear-gradient(135deg, rgba(103,232,249,0.20), rgba(96,165,250,0.20));
  border-color: rgba(103,232,249,0.20);
}
.message-meta {
  margin-top: 10px;
  color: rgba(239,244,255,0.48);
  font-size: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 420px;
}
.empty-state h3 { margin-bottom: 10px; color: var(--text); }

.composer {
  position: relative;
  z-index: 1;
  padding: 18px;
  border-top: 1px solid rgba(255,255,255,0.10);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}
textarea {
  resize: none;
  min-height: 58px;
  max-height: 160px;
}
.send-btn {
  width: 64px;
  border-radius: 20px;
  font-size: 24px;
}
.muted { color: var(--muted); font-size: 13px; }

#toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(10,14,28,0.86);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
}
.toast.good { border-color: rgba(52,211,153,0.35); }
.toast.bad { border-color: rgba(251,113,133,0.35); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1100px) {
  body { overflow: auto; }
  .shell { height: auto; min-height: calc(100vh - 28px); }
  .auth-screen, .app-screen { grid-template-columns: 1fr; }
  .side-columns { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .shell { width: calc(100vw - 14px); margin: 7px auto; }
  .auth-left, .auth-right, .sidebar, .chat-area { padding: 16px; }
  .auth-left h1 { font-size: 42px; }
  .feature-grid { grid-template-columns: 1fr; }
  .chat-header { padding: 18px 16px; }
  .messages { padding: 12px 16px 10px; }
  .composer { padding: 14px; }
  .chat-title { font-size: 22px; }
  .message-bubble { max-width: 86%; }
}
