:root {
  --bg: #09090b;
  --panel: rgba(18, 18, 24, 0.88);
  --panel-2: rgba(24, 24, 31, 0.9);
  --line: rgba(255,255,255,0.08);
  --muted: #9ea0aa;
  --text: #f5f7fb;
  --accent: #7c5cff;
  --accent-2: #a58bff;
  --success: #1ec28b;
  --danger: #ff5d73;
  --shadow: 0 30px 80px rgba(0,0,0,0.45);
  --radius: 24px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 20%, rgba(124,92,255,0.18), transparent 25%),
    radial-gradient(circle at 85% 10%, rgba(30,194,139,0.08), transparent 20%),
    linear-gradient(180deg, #07070a 0%, #0c0d12 100%);
}

.app-shell {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.glow {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  opacity: 0.35;
}
.glow-1 { background: #6f5cff; top: -120px; left: -80px; }
.glow-2 { background: #00c2a8; right: -120px; bottom: -120px; }

.view { display: none; padding: 28px; min-height: 100vh; position: relative; z-index: 1; }
.view.active { display: block; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto 28px;
  max-width: 1280px;
}
.topbar.compact { max-width: 900px; }

.brand-wrap { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #1f2030);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 8px 30px rgba(124,92,255,0.35);
}
.brand-title { font-weight: 700; font-size: 1.15rem; }
.brand-sub { font-size: 0.88rem; color: var(--muted); }

.hero-grid {
  max-width: 1280px; margin: 0 auto;
  display: grid; gap: 28px;
  grid-template-columns: 1.2fr 0.8fr;
  align-items: stretch;
}
.card, .sidebar, .chat-panel, .settings-panel {
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}
.soft-border { border: 1px solid var(--line); }
.hero-copy { padding: 40px; }
.create-card { padding: 34px; display: flex; flex-direction: column; justify-content: center; }
.badge {
  display: inline-flex; padding: 8px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  color: #d9dcf5; font-size: 0.88rem; margin-bottom: 20px;
}
h1 {
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  line-height: 0.98; margin: 0 0 18px;
  letter-spacing: -0.05em;
}
h2 { font-size: 2rem; margin: 0 0 10px; letter-spacing: -0.03em; }
.hero-text, .muted { color: var(--muted); line-height: 1.65; }
.feature-list { margin-top: 26px; display: grid; gap: 14px; }
.feature-item { display: flex; gap: 12px; align-items: center; color: #e9ebf6; }
.feature-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 18px rgba(165,139,255,0.8); }
.section-label { color: #c6cbff; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 10px; }
.stack-lg { display: grid; gap: 18px; }
.field-label { display: block; margin-bottom: 8px; color: #e6e9f7; font-size: 0.95rem; }
.text-input, .text-area, .composer-input {
  width: 100%; border: 1px solid rgba(255,255,255,0.08); outline: none;
  background: rgba(255,255,255,0.035); color: var(--text); border-radius: 16px;
  padding: 16px 18px; font-size: 1rem;
}
.text-input:focus, .text-area:focus, .composer-input:focus { border-color: rgba(124,92,255,0.65); box-shadow: 0 0 0 4px rgba(124,92,255,0.12); }
.text-area { min-height: 120px; resize: vertical; }
.primary-btn, .ghost-btn, .icon-btn, .attach-btn {
  border: none; cursor: pointer; transition: 0.2s ease; font: inherit;
}
.primary-btn {
  background: linear-gradient(135deg, var(--accent), #906dff);
  color: white; padding: 15px 20px; border-radius: 16px; font-weight: 700;
  box-shadow: 0 14px 30px rgba(124,92,255,0.32);
}
.primary-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.ghost-btn, .icon-btn {
  background: rgba(255,255,255,0.05); color: var(--text); padding: 12px 16px;
  border-radius: 14px; border: 1px solid rgba(255,255,255,0.08);
}
.ghost-btn:hover, .icon-btn:hover, .attach-btn:hover { background: rgba(255,255,255,0.08); }

.center-wrap { min-height: calc(100vh - 110px); display: grid; place-items: center; }
.profile-card { width: min(100%, 680px); padding: 34px; }
.avatar-builder { display: flex; justify-content: center; margin: 18px 0 24px; }
.avatar-upload {
  width: 110px; height: 110px; border-radius: 28px; overflow: hidden;
  border: 1px dashed rgba(255,255,255,0.18); display: grid; place-items: center;
  background: rgba(255,255,255,0.03); cursor: pointer;
}
.avatar-upload img, .current-user img, .profile-mini img { width: 100%; height: 100%; object-fit: cover; display: none; }
#avatarFallback { font-size: 2rem; color: var(--muted); }

.messenger-view {
  display: none;
  min-height: 100vh;
  padding: 18px;
  gap: 18px;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
}
.messenger-view.active { display: grid; }
.sidebar, .chat-panel, .settings-panel { min-height: calc(100vh - 36px); }
.sidebar {
  padding: 18px;
  display: flex; flex-direction: column; gap: 16px;
}
.sidebar-top, .current-user, .settings-head, .chat-header {
  display: flex; align-items: center; justify-content: space-between;
}
.current-user { gap: 14px; justify-content: flex-start; }
.current-user img, .profile-mini img {
  width: 52px; height: 52px; border-radius: 18px; background: #1d1e25;
}
.sidebar-name { font-weight: 700; }
.sidebar-username { color: var(--muted); font-size: 0.92rem; margin-top: 4px; }
.search-box {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-radius: 16px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
}
.search-box input {
  width: 100%; background: transparent; border: none; outline: none; color: var(--text); font: inherit;
}
.chat-list { display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.chat-item {
  display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 18px; cursor: pointer;
  background: rgba(255,255,255,0.025); border: 1px solid transparent;
}
.chat-item.active, .chat-item:hover { background: rgba(124,92,255,0.1); border-color: rgba(124,92,255,0.22); }
.avatar {
  width: 46px; height: 46px; border-radius: 16px; background: linear-gradient(135deg, #2b2d3a, #121318);
  display: grid; place-items: center; color: #d2d8f6; font-weight: 700; flex-shrink: 0;
}
.avatar.tiny { width: 42px; height: 42px; border-radius: 14px; }
.chat-item-main { min-width: 0; }
.chat-item-name { font-weight: 600; }
.chat-item-preview, .chat-meta { color: var(--muted); font-size: 0.9rem; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-panel {
  display: grid; grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
.chat-header { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.chat-header-user { display: flex; gap: 12px; align-items: center; }
.chat-name { font-weight: 700; }
.messages-area {
  padding: 20px 22px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    radial-gradient(circle at top, rgba(124,92,255,0.07), transparent 25%),
    linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0.02));
}
.message {
  max-width: min(72%, 540px);
  padding: 14px 16px;
  border-radius: 20px;
  line-height: 1.5;
  position: relative;
}
.message.incoming {
  align-self: flex-start;
  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.06);
}
.message.outgoing {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(124,92,255,0.84), rgba(90,74,255,0.95));
}
.message-meta {
  margin-top: 8px; font-size: 0.75rem; opacity: 0.74;
}
.message img, .message video {
  max-width: 100%; border-radius: 14px; margin-top: 10px; display: block;
}
.composer-wrap { padding: 16px 18px 18px; border-top: 1px solid var(--line); }
.composer { display: flex; gap: 12px; align-items: center; }
.attach-btn {
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08); color: white; font-size: 1.35rem;
}
.composer-input { flex: 1; }
.send-btn { min-width: 110px; }
.upload-preview {
  margin-bottom: 12px; padding: 12px; border-radius: 16px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  color: var(--muted);
}
.upload-preview img, .upload-preview video { max-width: 120px; border-radius: 12px; display: block; margin-top: 8px; }
.hidden { display: none !important; }

.settings-panel {
  padding: 20px;
  display: flex; flex-direction: column; gap: 18px;
}
.settings-group {
  padding: 16px; border-radius: 18px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
}
.settings-note { color: var(--muted); line-height: 1.65; }
.settings-note.compact { margin-top: 5px; }
.lang-row { display: flex; gap: 10px; margin-top: 10px; }
.profile-mini { display: flex; gap: 12px; align-items: center; }

@media (max-width: 1100px) {
  .hero-grid, .messenger-view.active {
    grid-template-columns: 1fr;
  }
  .settings-panel { min-height: auto; }
  .sidebar, .chat-panel, .settings-panel { min-height: auto; }
}

@media (max-width: 720px) {
  .view, .messenger-view { padding: 14px; }
  .hero-copy, .create-card, .profile-card { padding: 24px; }
  h1 { font-size: 2.4rem; }
  .message { max-width: 88%; }
  .composer { flex-wrap: wrap; }
  .send-btn { width: 100%; }
}

.error-text {
  margin-top: 14px;
  color: #ff8b9c;
  font-size: 0.95rem;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  border-radius: 18px;
  border: 1px dashed rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
}

.empty-state.large {
  margin: auto;
  max-width: 420px;
  text-align: center;
}

.avatar-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
}
