.chat-widget {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 9999;
  font-family: 'DM Sans', system-ui, sans-serif;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 12px;
}

/* ── Toggle button ── */
.chat-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2c4530, #3a6645 60%, #6b9175);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(58,102,69,.45), 0 2px 8px rgba(0,0,0,.15);
  transition: transform .25s ease, box-shadow .25s ease;
  position: relative;
  flex-shrink: 0;
}
.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(58,102,69,.55);
}
.chat-toggle .icon-open,
.chat-toggle .icon-close {
  position: absolute;
  transition: opacity .2s, transform .28s cubic-bezier(.16,1,.3,1);
}
.chat-toggle .icon-close { opacity: 0; transform: rotate(-90deg) scale(.5); }
.chat-widget.is-open .chat-toggle .icon-open  { opacity: 0; transform: rotate(90deg) scale(.5); }
.chat-widget.is-open .chat-toggle .icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* ── Panel ── */
.chat-panel {
  width: 360px;
  max-width: calc(100vw - 2rem);
  height: 520px;
  background: #f4f6f4;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;
  transform: scale(.88) translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform .32s cubic-bezier(.16,1,.3,1), opacity .25s ease;
}
.chat-widget.is-open .chat-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
.chat-header {
  background: linear-gradient(135deg, #1e3324 0%, #2c4530 50%, #3a6645 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: 2px solid rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: .8rem;
  color: #fff;
  letter-spacing: .03em;
}
.chat-header-info { flex: 1; }
.chat-header-name {
  color: #fff;
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.25;
}
.chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: rgba(255,255,255,.72);
  margin-top: 2px;
}
.chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7edd9a;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(126,221,154,.25);
}

/* ── Messages area ── */
.chat-messages {
  flex: 1;
  padding: 14px 14px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }

/* ── Bubbles ── */
.msg {
  max-width: 82%;
  font-size: .875rem;
  line-height: 1.55;
  animation: msgIn .22s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.bot {
  align-self: flex-start;
  background: #fff;
  color: #1a1a1a;
  padding: 9px 13px;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,.07);
}
.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #3a6645, #5a8a68);
  color: #fff;
  padding: 9px 13px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 8px rgba(58,102,69,.28);
}

/* ── Typing dots ── */
.msg.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 13px 15px;
  background: #fff;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,.07);
}
.msg.typing span {
  width: 7px;
  height: 7px;
  background: #9bbda6;
  border-radius: 50%;
  animation: tpulse 1.4s infinite;
}
.msg.typing span:nth-child(2) { animation-delay: .2s; }
.msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes tpulse {
  0%,60%,100% { transform: translateY(0);    opacity: .45; }
  30%         { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ── */
.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #e8ebe8;
  flex-shrink: 0;
}
.chat-form input {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid #e0e4e0;
  border-radius: 24px;
  font-size: .88rem;
  font-family: inherit;
  background: #f6f8f6;
  outline: none;
  transition: border-color .2s, background .2s;
  color: #1a1a1a;
}
.chat-form input::placeholder { color: #aaa; }
.chat-form input:focus { border-color: #3a6645; background: #fff; }
.chat-form input:disabled { opacity: .55; }
.chat-form button[type="submit"] {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a6645, #5a8a68);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, opacity .2s;
  box-shadow: 0 3px 10px rgba(58,102,69,.35);
}
.chat-form button[type="submit"]:hover  { transform: scale(1.08); }
.chat-form button[type="submit"]:active { transform: scale(.96); }
.chat-form button[type="submit"]:disabled { opacity: .45; }

@media (max-width:420px) {
  .chat-widget { right: .75rem; bottom: .75rem; }
  .chat-panel  { width: calc(100vw - 1.5rem); height: 78svh; }
}
