.neesac-chat-root {
  --chat-primary: #d65f1f;
  --chat-primary-dark: #da8a49;
  --chat-glow-1: #ff6b9d;
  --chat-glow-2: #c084fc;
  --chat-glow-3: #60a5fa;
  --chat-glow-4: #34d399;
  --chat-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-family: var(--chat-font);
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}
.neesac-chat-root *,
.neesac-chat-root *::before,
.neesac-chat-root *::after {
  box-sizing: border-box;
}

/* Host-site resets (theme overrides) */
.neesac-chat-root button,
.neesac-chat-root input,
.neesac-chat-root textarea {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  line-height: normal;
  letter-spacing: normal;
  text-transform: none;
  float: none;
  vertical-align: baseline;
}
.neesac-chat-root button {
  font-family: inherit;
  text-decoration: none;
  box-shadow: none;
}
.neesac-chat-root button::before,
.neesac-chat-root button::after {
  content: none !important;
  display: none !important;
}
.neesac-chat-root #neesac-lead-title {
  margin: 0;
  font-size: 18px !important;
  line-height: 1.2;
  font-weight: 700;
  color: var(--chat-primary);
}
.neesac-chat-root img {
  max-width: none;
  border: 0;
  vertical-align: middle;
}
.neesac-chat-root svg {
  display: block;
  max-width: none;
  max-height: none;
  overflow: visible;
  flex-shrink: 0;
}

/* ── Backdrop ── */
.neesac-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147482998;
  background: rgba(243, 244, 246, 0.78);
  backdrop-filter: blur(28px) saturate(1.15);
  -webkit-backdrop-filter: blur(28px) saturate(1.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, backdrop-filter 0.35s ease;
}
.neesac-backdrop[data-neesac-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

/* ── Center conversation modal ── */
.neesac-modal {
  position: fixed;
  left: 50%;
  top: 10px;
  transform: translateX(-50%) scale(0.96);
  z-index: 2147483000;
  width: min(720px, calc(100vw - 32px));
  height: min(460px, calc(100vh - 120px));
  min-height: min(380px, calc(100vh - 120px));
  max-height: calc(100vh - 120px);
  background: #f3f4f6;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.neesac-modal[data-neesac-open="true"] {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.neesac-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.neesac-modal-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: #111;
}
.neesac-modal-logo {
  height: 36px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  display: block;
}
.neesac-modal-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.neesac-modal-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: background 0.15s, color 0.15s;
}
.neesac-modal-btn:hover {
  background: #f3f4f6;
  color: #111;
}
.neesac-modal-btn svg {
  width: 18px;
  height: 18px;
}

.neesac-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  scroll-behavior: smooth;
}

/* User message */
.neesac-msg-row.user {
  display: flex;
  justify-content: flex-end;
}
.neesac-msg.user {
  margin: 0;
  padding: 12px 18px;
  border-radius: 18px;
  max-width: 75%;
  line-height: 1.55;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  background: #e5e7eb;
  color: #111;
}

/* Bot message card */
.neesac-msg-row.bot {
  display: flex;
  justify-content: flex-start;
}
.neesac-msg.bot {
  margin: 0;
  padding: 16px 18px;
  border-radius: 16px;
  max-width: 88%;
  line-height: 1.6;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.neesac-msg.bot a {
  color: var(--chat-primary);
  text-decoration: underline;
}
.neesac-bot-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.neesac-bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
}
.neesac-bot-name {
  font-weight: 700;
  font-size: 14px;
  color: #111;
}

/* Loading skeleton */
.neesac-msg.bot.loading .neesac-bot-body {
  display: none;
}
.neesac-skeleton {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}
.neesac-msg.bot.loading .neesac-skeleton {
  display: flex;
}
.neesac-skeleton-line {
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: neesac-shimmer 1.4s infinite;
}
.neesac-skeleton-line:nth-child(1) { width: 92%; }
.neesac-skeleton-line:nth-child(2) { width: 68%; }
@keyframes neesac-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Bottom dock ── */
.neesac-dock {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 2147483001;
  width: min(640px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  transition: bottom 0.35s ease;
  isolation: isolate;
}
.neesac-dock[data-neesac-chat="true"] {
  bottom: 28px;
}

/* Welcome / lead card */
.neesac-welcome-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: max-height 0.4s ease, opacity 0.3s ease, transform 0.3s ease, padding 0.3s ease;
  padding: 0 20px;
}
.neesac-welcome-card[data-neesac-open="true"] {
  max-height: 480px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  padding: 18px 20px 16px;
}

.neesac-welcome-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.neesac-welcome-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
  margin-top: 2px;
}
.neesac-welcome-info {
  flex: 1;
  min-width: 0;
}
.neesac-welcome-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.neesac-welcome-name {
  font-weight: 700;
  font-size: 15px;
  color: #111;
}
.neesac-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
.neesac-online-label {
  font-size: 13px;
  color: #6b7280;
}
.neesac-welcome-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #374151;
}
.neesac-welcome-close {
  border: none;
  background: transparent;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #9ca3af;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.neesac-welcome-close:hover {
  background: #f3f4f6;
  color: #111;
}

/* Lead form inside welcome card */
.neesac-chat-lead {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid #f0f0f0;
  padding-top: 14px;
  margin-top: 4px;
}
.neesac-chat-lead h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--chat-primary);
}
.neesac-lead-fields {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.neesac-lead-field {
  flex: 1;
  min-width: 0;
}
.neesac-chat-lead label {
  font-weight: 600;
  font-size: 12px;
  color: #374151;
  display: block;
  margin-bottom: 4px;
}
.neesac-chat-lead input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.neesac-chat-lead input:focus {
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-primary) 15%, transparent);
}
.neesac-lead-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.neesac-chat-start {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s;
  text-align: center;
  display: block;
}
.neesac-chat-start:hover {
  filter: brightness(1.05);
}

/* ── Glowing input bar ── */
.neesac-input-bar-wrap {
  position: relative;
  padding: 2px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--chat-glow-1), var(--chat-glow-2), var(--chat-glow-3), var(--chat-glow-4));
  box-shadow: 0 4px 24px rgba(192, 132, 252, 0.25), 0 0 40px rgba(255, 107, 157, 0.12);
  animation: neesac-glow-pulse 4s ease-in-out infinite;
  overflow: hidden;
}
@keyframes neesac-glow-pulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(192, 132, 252, 0.25), 0 0 40px rgba(255, 107, 157, 0.12); }
  50% { box-shadow: 0 4px 32px rgba(96, 165, 250, 0.3), 0 0 50px rgba(52, 211, 153, 0.15); }
}

.neesac-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 999px;
  padding: 6px 6px 6px 6px;
  min-height: 52px;
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
}

.neesac-dock-avatar {
  width: 40px !important;
  height: 40px !important;
  max-width: 40px !important;
  max-height: 40px !important;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  padding: 3px;
  flex: 0 0 40px;
  margin-left: 2px;
}

.neesac-input-bar input {
  flex: 1 1 auto;
  width: auto !important;
  min-width: 0;
  max-width: none;
  border: none !important;
  outline: none;
  font-size: 15px;
  font-family: inherit;
  background: transparent !important;
  color: #111;
  padding: 8px 4px;
  box-shadow: none !important;
  height: auto;
  line-height: 1.4;
}
.neesac-input-bar input::placeholder {
  color: #9ca3af;
}

.neesac-send-circle {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50%;
  border: none !important;
  cursor: pointer;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark)) !important;
  color: #fff !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, filter 0.15s;
}
.neesac-send-circle:hover {
  transform: scale(1.06);
  filter: brightness(1.05);
}
.neesac-send-circle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.neesac-send-circle svg {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  min-height: 18px !important;
  display: block;
  pointer-events: none;
}

.neesac-wave-icon {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50%;
  border: none !important;
  background: transparent !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  color: #9ca3af;
  transition: color 0.15s, background 0.15s;
}
.neesac-wave-icon:hover {
  color: var(--chat-primary);
  background: #f9fafb !important;
}
.neesac-wave-icon svg {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  pointer-events: none;
}

/* Hide old launcher - dock replaces it */
.neesac-chat-launcher {
  display: none !important;
}

/* Scroll-to-bottom hint */
.neesac-scroll-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  z-index: 2;
}
.neesac-messages-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 640px) {
  .neesac-dock {
    width: calc(100vw - 20px);
    bottom: 16px;
  }
  .neesac-modal {
    top: 10px;
    width: calc(100vw - 16px);
    height: min(420px, calc(100vh - 110px));
    min-height: min(320px, calc(100vh - 110px));
    max-height: calc(100vh - 110px);
    border-radius: 16px;
  }
  .neesac-msg.user,
  .neesac-msg.bot {
    max-width: 92%;
  }
  .neesac-lead-actions {
    flex-direction: column;
  }
  .neesac-lead-fields {
    flex-direction: column;
    gap: 10px;
  }
}
