#ai-trigger {
  position: fixed; top: auto; left: auto; right: 2rem; bottom: 2rem;
  z-index: 1000;
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
}
#ai-trigger.chat-open { opacity: 0; pointer-events: none; }
#chat-btn {
  width: 96px; height: 96px;
  background: none; border: none; padding: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease;
}
#chat-btn:hover { transform: translateY(3px); }
.chat-btn-memoji { width: 100%; height: 100%; object-fit: contain; }
#chat-btn svg { width: 34px; height: 34px; flex-shrink: 0; }
#chat-btn .icon-close { display: none; }
#chat-btn.open .icon-close line { stroke: #0f172a; }
#chat-btn.open .chat-btn-memoji { display: none; }
#chat-btn.open .icon-close { display: block; }
.ai-trigger-label {
  font-family: 'Onest', sans-serif;
  font-size: 0.76rem; font-weight: 600; color: #475569;
  white-space: nowrap;
}

#chat-panel {
  position: fixed; bottom: 5.5rem; right: 2rem; z-index: 999;
  width: 360px; max-height: 520px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(15,23,42,0.14);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#chat-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

.chat-header {
  padding: 1rem 1.2rem 0.8rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; gap: 0.75rem;
}
#chat-close {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  border: none; background: #f1f5f9; color: #475569;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s ease;
}
#chat-close:hover { background: #e5e7eb; }
#chat-close svg { width: 15px; height: 15px; }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #0f172a;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Onest', sans-serif; font-weight: 600; font-size: 0.78rem; color: #fff;
}
.chat-header-info { flex: 1; }
.chat-header-name { font-size: 0.88rem; font-weight: 600; color: #0f172a; }
.chat-header-status { font-size: 0.7rem; color: #64748b; display: flex; align-items: center; gap: 0.4rem; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #16a34a; display: inline-block; }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 1rem 1rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.75rem;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

.msg { max-width: 82%; font-size: 0.83rem; line-height: 1.55; animation: msgIn 0.2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.user {
  align-self: flex-end;
  background: #0f172a;
  color: #fff; border-radius: 16px 16px 4px 16px;
  padding: 0.6rem 0.9rem;
}
.msg.bot {
  align-self: flex-start;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  color: #0f172a; border-radius: 16px 16px 16px 4px;
  padding: 0.6rem 0.9rem;
}
.msg.typing span {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #94a3b8; margin: 0 2px;
  animation: bounce 1.2s ease infinite;
}
.msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-5px); } }

.chat-input-row {
  padding: 0.75rem 1rem 1rem;
  display: flex; gap: 0.5rem; align-items: center;
  border-top: 1px solid #f1f5f9;
}
#chat-input {
  flex: 1; border: 1px solid #e5e7eb; border-radius: 100px;
  padding: 0.55rem 1rem; font-family: 'Onest', sans-serif; font-size: 0.82rem;
  background: #fff; color: #0f172a; outline: none;
  transition: border-color 0.2s;
}
#chat-input:focus { border-color: #94a3b8; }
#chat-input::placeholder { color: #94a3b8; }
#chat-send {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: #0f172a;
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform 0.15s ease;
}
#chat-send:hover { transform: translateY(2px); }
#chat-send svg { width: 16px; height: 16px; }

@media (max-width: 900px) {
  /* anchor from the top+bottom instead of a fixed height hanging off the
     bottom — the on-screen keyboard only ever eats into the bottom of the
     viewport, so a top-anchored panel can never end up hidden behind it,
     whether the keyboard opens immediately or later when the input is tapped */
  #chat-panel {
    top: 5.5rem; bottom: 1.25rem; left: 1rem; right: 1rem;
    width: auto; max-height: none;
  }
}
