/* ─── Tokens ──────────────────────────────────────────────────────── */
:root {
  --bg: #2e2e32;
  --surface: #0a0a0a;
  --surface-raised: #111111;
  --bubble-bot: #162723;
  --border: rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.10);
  --text-primary: #f5f5f5;
  --text-secondary: rgba(255,255,255,0.55);
  --text-tertiary: rgba(255,255,255,0.35);
  --accent: #5de4c7;
  --accent-dim: rgba(93,228,199,0.12);
  --accent-glow: rgba(93,228,199,0.06);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --ease-out-expo: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t: 0.25s;
  --ease: cubic-bezier(.4,0,.2,1);
}

/* ─── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Noise overlay ───────────────────────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
}

/* ─── Ambient glow ────────────────────────────────────────────────── */
.ambient-glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(180px);
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}

.glow-1 {
  top: -200px;
  left: -100px;
  background: var(--accent);
}

.glow-2 {
  bottom: -300px;
  right: -200px;
  background: #7c5bf5;
  opacity: 0.05;
}

/* ═══════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════ */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100dvh;
  min-height: 100dvh;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  padding: 24px;
  gap: 24px;
}

/* ─── Left panel: Profile ─────────────────────────────────────────── */
.profile-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  opacity: 0;
  transform: translateY(24px);
  animation: fadeUp 1s var(--ease-out-expo) 0.2s forwards;
}

/* Double-bezel photo container */
.photo-shell {
  padding: 6px;
  background: var(--accent-glow);
  border: 1px solid var(--border-light);
  border-radius: 2rem;
  margin-bottom: 32px;
}

.photo-core {
  width: 120px;
  height: 120px;
  border-radius: calc(2rem - 6px);
  overflow: hidden;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.08);
}

.photo-core img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Eyebrow */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 9999px;
  background: var(--accent-dim);
  border: 1px solid rgba(93,228,199,0.15);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}

.eyebrow-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.5s ease infinite;
}

.name {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 3.5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.lead {
  font-size: clamp(0.95rem, 1.2vw, 1.15rem);
  font-weight: 300;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 420px;
}

.lead strong {
  color: var(--text-primary);
  font-weight: 500;
}

/* Social links */
.socials {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.social-link {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: all 500ms var(--ease-out-expo);
}

.social-link:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.social-link svg {
  width: 18px;
  height: 18px;
}

/* ─── Right panel: Chat ───────────────────────────────────────────── */
.chat-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  opacity: 0;
  transform: translateY(24px);
  animation: fadeUp 1s var(--ease-out-expo) 0.5s forwards;
}

/* Chat double-bezel */
.chat-shell {
  width: 100%;
  max-width: 480px;
  height: min(620px, calc(100dvh - 80px));
  padding: 6px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 2rem;
}

.chat-core {
  width: 100%;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(2rem - 6px);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.04), 0 24px 80px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════
   CHAT COMPONENTS
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Chat header ─────────────────────────────────────────────────── */
.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--accent-dim);
  border: 1px solid rgba(93,228,199,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-avatar svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-info h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 6px rgba(52,211,153,0.5);
  animation: statusPulse 2.4s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(52,211,153,0.5); }
  50% { opacity: 0.5; box-shadow: 0 0 2px rgba(52,211,153,0.2); }
}

/* ─── Notification bell ───────────────────────────────────────────── */
.chat-notif {
  color: var(--text-tertiary);
  cursor: default;
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
  position: relative;
}

.chat-notif.has-unread {
  color: var(--accent);
  cursor: pointer;
}

.chat-notif.has-unread:hover {
  background: rgba(255,255,255,0.05);
}

.chat-notif-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--text-primary);
  color: var(--bg);
  font-size: 11px;
  font-weight: 400;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 10;
}

.chat-notif-tooltip.show-tooltip {
  opacity: 1;
}

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--bg);
  font-size: 10px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  font-family: var(--font-display);
}

.chat-notif.has-unread .notif-badge {
  display: flex;
}

/* ─── Messages ────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: none;
}

.chat-messages::-webkit-scrollbar { display: none; }

/* Date separator (kept for compatibility) */
.msg-date-sep {
  text-align: center;
  font-size: .7rem;
  color: var(--text-tertiary);
  margin: 8px 0 6px;
  font-weight: 300;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px);
  animation: msg-in .3s var(--ease-out-expo) forwards;
}

.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; width: 100%; justify-content: flex-start; }

@keyframes msg-in {
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 3px;
  align-self: flex-end;
  overflow: hidden;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg.user .msg-avatar { display: none; }

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 85%;
}

.msg.bot .msg-body { align-items: flex-start; }
.msg.user .msg-body { align-items: flex-end; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  position: relative;
}

.msg.bot .msg-bubble {
  background: var(--bubble-bot);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
  color: rgba(255,255,255,0.8);
  font-weight: 400;
}

.msg.user .msg-bubble {
  background: var(--accent);
  color: #050505;
  border-bottom-right-radius: 2px;
  font-weight: 500;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  justify-content: flex-end;
}

.msg-time {
  font-size: .66rem;
  color: var(--text-tertiary);
  font-weight: 300;
  line-height: 1;
}

.msg.user .msg-time { color: rgba(5,5,5,0.45); }

.msg-ticks {
  font-size: .63rem;
  line-height: 1;
  color: rgba(5,5,5,0.5);
  display: none;
}

.msg.user .msg-ticks { display: inline; }

/* ─── Quick-action chips ──────────────────────────────────────────── */
.msg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-left: 32px;
}

.chip {
  padding: 8px 16px;
  border-radius: 9999px;
  border: 1px solid var(--border-light);
  font-size: .8rem;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  transition: all 400ms var(--ease-out-expo);
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ─── Typing indicator ────────────────────────────────────────────── */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  border-bottom-left-radius: 2px;
  width: fit-content;
  margin-left: 32px;
}

.typing-indicator.active { display: flex; position: relative; }

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
  animation: typingBounce 1s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

/* ─── Chat input ──────────────────────────────────────────────────── */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chat-input-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  padding: 4px 4px 4px 18px;
  border-radius: 9999px;
  background: #222222;
  border: 1px solid var(--border);
  transition: border-color 400ms var(--ease-out-expo);
}

.chat-input-wrap:focus-within {
  border-color: var(--border-light);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  resize: none;
  max-height: 90px;
  min-height: 28px;
  padding: 6px 0;
}

.chat-input::placeholder {
  color: var(--text-tertiary);
}

.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 400ms var(--ease-out-expo);
}

.chat-send:hover {
  transform: scale(1.06);
  box-shadow: 0 0 20px rgba(93,228,199,0.3);
}

.chat-send:active {
  transform: scale(0.95);
}

.chat-send svg {
  width: 15px;
  height: 15px;
  color: #050505;
  stroke: #050505;
}

/* ═══════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════ */
@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

@keyframes chat-buzz {
  0%,100% { transform: translateX(0); }
  15%     { transform: translateX(-5px); }
  30%     { transform: translateX(5px); }
  45%     { transform: translateX(-4px); }
  60%     { transform: translateX(4px); }
  75%     { transform: translateX(-2px); }
  90%     { transform: translateX(2px); }
}

.layout.buzz {
  animation: chat-buzz 0.55s ease-in-out;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    padding: 16px;
    gap: 0;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .profile-panel {
    padding: 0 8px;
    align-items: center;
    text-align: center;
    justify-content: center;
    min-height: 0;
  }

  .lead {
    max-width: 100%;
  }

  .socials {
    justify-content: center;
  }

  .name {
    font-size: 1.8rem;
  }

  .photo-core {
    width: 88px;
    height: 88px;
  }

  /* Chat minimized at bottom */
  .chat-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    justify-content: stretch;
    opacity: 1;
    transform: none;
    animation: none;
  }

  .chat-shell {
    max-width: 100%;
    height: 70dvh;
    border-radius: 2rem 2rem 0 0;
    transform: translateY(calc(100% - 80px));
    transition: transform .35s var(--ease-out-expo);
  }

  .chat-shell.open {
    transform: translateY(0);
  }

  .chat-core {
    border-radius: calc(2rem - 6px) calc(2rem - 6px) 0 0;
  }

  .chat-header {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
}
