:root {
  --purple-900: #2a0f4b;
  --purple-800: #3a1363;
  --purple-700: #4d1a7a;
  --purple-600: #6a28a5;
  --purple-500: #7e36c7;
  --purple-400: #9a5fe0;
  --ink-900: #12101b;
  --ink-700: #2c2638;
  --ink-500: #4b415a;
  --ink-300: #786b94;
  --slate-100: #f4f2f9;
  --slate-200: #ebe7f3;
  --slate-300: #ded7ea;
  --white: #ffffff;
}

body[data-theme="sunset"] {
  --bg-1: #ffb86b;
  --bg-2: #f06767;
  --bg-3: #5b2a49;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-border: rgba(255, 255, 255, 0.15);
  --bubble-me: linear-gradient(135deg, #ff9a6b, #ff6b8b);
  --bubble-them: #fff4f0;
  --accent: #ff6b8b;
}

body[data-theme="purple"] {
  --bg-1: #6b2bbf;
  --bg-2: #3a1363;
  --bg-3: #190c2f;
  --panel: rgba(255, 255, 255, 0.95);
  --panel-border: rgba(255, 255, 255, 0.15);
  --bubble-me: linear-gradient(135deg, #b06cff, #7a2fe9);
  --bubble-them: #f4f2f9;
  --accent: #7e36c7;
}

body[data-theme="mint"] {
  --bg-1: #39c6b1;
  --bg-2: #117a6a;
  --bg-3: #0b3d36;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-border: rgba(255, 255, 255, 0.15);
  --bubble-me: linear-gradient(135deg, #52e3c2, #1bb39a);
  --bubble-them: #f1fbf9;
  --accent: #1bb39a;
}

body[data-theme="slate"] {
  --bg-1: #6d7b93;
  --bg-2: #343f52;
  --bg-3: #1f2533;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-border: rgba(255, 255, 255, 0.15);
  --bubble-me: linear-gradient(135deg, #7c8aa6, #4a5b77);
  --bubble-them: #f2f4f7;
  --accent: #5b6f92;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink-900);
  background: radial-gradient(circle at top left, var(--bg-1) 0%, var(--bg-2) 35%, var(--bg-3) 80%),
    linear-gradient(140deg, var(--bg-2) 10%, var(--bg-3) 60%);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 40px) 32px;
  background: radial-gradient(circle at 80% 0%, rgba(255, 255, 255, 0.08), transparent 45%);
}

.top-nav {
  position: static;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  color: var(--white);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: "Clash Display", "Space Grotesk", sans-serif;
  letter-spacing: 0.5px;
  font-size: 1.2rem;
}

.brand-badge {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.24);
  font-weight: 700;
  color: #fff;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  color: inherit;
  font-weight: 500;
  opacity: 0.9;
}

.nav-links a:hover {
  opacity: 1;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
  background: var(--bubble-me);
  color: #13071e;
  box-shadow: 0 10px 22px rgba(255, 107, 139, 0.35);
}

.btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.btn-small {
  padding: 8px 12px;
  font-size: 0.85rem;
  border-radius: 14px;
}

.btn:hover {
  transform: translateY(-1px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 24px;
  align-items: stretch;
}

.hero-copy {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 24px;
  color: #fff;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.75rem;
  margin: 0 0 12px;
}

.hero-copy h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.lead {
  margin: 0 0 20px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-card {
  background: var(--panel);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 18px 40px rgba(16, 8, 30, 0.3);
}

.card-title {
  font-weight: 700;
  margin-bottom: 12px;
}

.card-preview {
  display: grid;
  gap: 12px;
}

.preview-bubble {
  background: var(--bubble-them);
  border-radius: 16px;
  padding: 12px;
  color: var(--ink-700);
}

.preview-bubble.me {
  background: var(--bubble-me);
  color: #fff;
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
  gap: 24px;
}

.panel {
  background: var(--panel);
  min-height: 72px;
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(16, 8, 30, 0.25);
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--slate-200);
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink-900);
}

.status-chip {
  background: rgba(255, 255, 255, 0.6);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0 12px;
  flex: 1;
  overflow-y: auto;
  max-height: 60vh;
}

.message {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffd6f8, #a1b2ff);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--ink-700);
  overflow: hidden;
}

.bubble {
  background: var(--bubble-them);
  border-radius: 18px;
  padding: 12px 16px;
  color: var(--ink-700);
  line-height: 1.5;
}

.bubble.me {
  background: var(--bubble-me);
  color: #fdf8ff;
}

.message.me {
  grid-template-columns: 1fr auto;
}

.message.me .avatar {
  order: 2;
  background: linear-gradient(135deg, #ff9a6b, #ff6b8b);
  color: #fff;
}

.message.me .bubble {
  order: 1;
  justify-self: end;
  text-align: right;
}

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-200);
  flex-wrap: wrap;
}

.composer input {
  flex: 1 1 240px;
  min-width: 0;
  border: 1px solid var(--slate-300);
  border-radius: 999px;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
}

.composer .icon-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bubble-them);
  cursor: pointer;
  font-weight: 600;
}

.composer .icon-btn.active {
  background: rgba(255, 107, 139, 0.18);
  border: 1px solid rgba(255, 107, 139, 0.35);
}

.preview-panel {
  display: none;
  gap: 12px;
  align-items: center;
  background: var(--bubble-them);
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  padding: 10px;
  margin-top: 10px;
}

.preview-panel.visible {
  display: flex;
}

.preview-thumb {
  width: 120px;
  height: 88px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: grid;
  place-items: center;
  border: 1px solid var(--slate-200);
}

.preview-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--ink-500);
}

.contacts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.search {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--slate-300);
  font-family: inherit;
}

.add-contact-panel {
  display: grid;
  gap: 10px;
  background: var(--bubble-them);
  border-radius: 16px;
  padding: 12px;
  border: 1px solid var(--slate-200);
}

.contact-result {
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--slate-200);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.contact-result.hidden {
  display: none;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  overflow: auto;
}

.contact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--bubble-them);
  border: 1px solid transparent;
  cursor: pointer;
}

.contact.active {
  background: rgba(255, 107, 139, 0.12);
  border-color: rgba(255, 107, 139, 0.25);
}

.contact-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contact .name {
  font-weight: 600;
}

.contact .last {
  font-size: 0.85rem;
  color: var(--ink-500);
}

.badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.75rem;
}

.top-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 6px;
  color: var(--ink-300);
  font-size: 0.85rem;
}

.empty-state {
  text-align: center;
  color: var(--ink-500);
  padding: 16px;
  border-radius: 14px;
  background: var(--bubble-them);
}

.muted {
  color: var(--ink-500);
  font-size: 0.85rem;
}

@media (max-width: 1024px) {
  .hero,
  .main {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .contacts-panel {
    order: -1;
  }
}

@media (max-width: 900px) {
  .brand-badge {
    width: 52px;
    height: 52px;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px;
  }

  .chat-window {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .top-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-links {
    width: 100%;
    justify-content: space-between;
    order: 3;
  }

  .nav-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .hero-copy,
  .hero-card {
    padding: 18px;
  }

  .composer {
    gap: 8px;
  }

  .composer input {
    flex-basis: 100%;
  }
}

@media (max-width: 560px) {
  .page {
    padding: 20px 16px 28px;
    gap: 18px;
  }

  .brand {
    font-size: 1.05rem;
  }

  .brand-badge {
    width: 46px;
    height: 46px;
  }

  .nav-links {
    justify-content: flex-start;
    gap: 12px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .nav-actions .btn {
    width: auto;
  }

  .composer .btn {
    width: auto;
  }

  .chat-window {
    padding-top: 12px;
  }

  .message {
    grid-template-columns: 1fr;
  }

  .message.me {
    grid-template-columns: 1fr;
  }

  .message.me .bubble,
  .message.me .avatar {
    justify-self: start;
    text-align: left;
  }
}
