.sp-ai-root {
  --sp-navy: #0a2540;
  --sp-blue: #00aeef;
  --sp-orange: #f5a623;
  --sp-ink: #14283d;
  --sp-muted: #607286;
  --sp-line: #dbe5ee;
  --sp-soft: #f4f8fb;
  position: relative;
  z-index: 2147483000;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--sp-ink);
}

.sp-ai-root *,
.sp-ai-root *::before,
.sp-ai-root *::after {
  box-sizing: border-box;
}

.sp-ai-launcher {
  position: fixed;
  right: 24px;
  bottom: 94px;
  z-index: 2147483001;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 0 18px 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 28px;
  background: linear-gradient(135deg, #0a2540 0%, #0e3a5d 100%);
  box-shadow: 0 12px 30px rgba(4, 23, 42, 0.3);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.sp-ai-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(4, 23, 42, 0.38);
}

.sp-ai-launcher.is-hidden {
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
}

.sp-ai-launcher-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--sp-blue);
}

.sp-ai-launcher-icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.sp-ai-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483002;
  display: flex;
  flex-direction: column;
  width: 392px;
  height: min(680px, calc(100dvh - 48px));
  overflow: hidden;
  border: 1px solid rgba(10, 37, 64, 0.16);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 26px 78px rgba(2, 19, 35, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.98);
  transform-origin: right bottom;
  transition: opacity 180ms ease, transform 180ms ease;
}

.sp-ai-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.sp-ai-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #0a2540 0%, #103d61 100%);
  color: #fff;
}

.sp-ai-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 12px;
  background: linear-gradient(145deg, #00aeef 0%, #007cab 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.4px;
}

.sp-ai-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.sp-ai-heading strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-ai-heading span {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  line-height: 1.2;
}

.sp-ai-heading i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #43e59e;
  box-shadow: 0 0 0 3px rgba(67, 229, 158, 0.13);
}

.sp-ai-header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

.sp-ai-text-btn,
.sp-ai-icon-btn {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sp-ai-text-btn {
  padding: 7px 7px;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 10px;
  font-weight: 650;
}

.sp-ai-text-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sp-ai-icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
}

.sp-ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sp-ai-icon-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.sp-ai-notice {
  flex: 0 0 auto;
  display: flex;
  gap: 7px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--sp-line);
  background: #f7fafc;
  color: #53677a;
  font-size: 10.5px;
  line-height: 1.45;
}

.sp-ai-notice span {
  flex: 1 1 auto;
}

.sp-ai-notice a {
  flex: 0 0 auto;
  color: #0879a8;
  font-weight: 650;
  text-decoration: underline;
}

.sp-ai-messages {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 14px 8px;
  background:
    radial-gradient(circle at 8% 5%, rgba(0, 174, 239, 0.055), transparent 34%),
    #fff;
  scroll-behavior: smooth;
}

.sp-ai-message {
  display: flex;
  flex-direction: column;
  margin: 0 0 12px;
  animation: sp-ai-in 180ms ease both;
}

@keyframes sp-ai-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sp-ai-user {
  align-items: flex-end;
}

.sp-ai-assistant {
  align-items: flex-start;
}

.sp-ai-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid var(--sp-line);
  border-radius: 4px 14px 14px 14px;
  background: #f4f8fb;
  color: #24384c;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.sp-ai-user .sp-ai-bubble {
  border-color: #0a2540;
  border-radius: 14px 4px 14px 14px;
  background: var(--sp-navy);
  color: #fff;
}

.sp-ai-bubble a {
  color: #007caa;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sp-ai-user .sp-ai-bubble a {
  color: #9be8ff;
}

.sp-ai-handoff {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: 92%;
  margin-top: 7px;
  color: var(--sp-muted);
  font-size: 11px;
  line-height: 1.4;
}

.sp-ai-handoff button {
  padding: 7px 10px;
  border: 1px solid #00a3de;
  border-radius: 8px;
  background: #eefaff;
  color: #006f99;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.sp-ai-handoff button:hover {
  background: #dff6ff;
}

.sp-ai-direct-contact {
  max-width: 92%;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #b9d9e8;
  border-radius: 11px;
  background: #f5fbfe;
  color: #24384c;
  font-size: 11px;
  line-height: 1.45;
}

.sp-ai-direct-contact strong {
  display: block;
  margin-bottom: 7px;
  color: var(--sp-navy);
  font-size: 12px;
}

.sp-ai-direct-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.sp-ai-direct-actions a,
.sp-ai-direct-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #0d8f7a;
  border-radius: 8px;
  background: #0d8f7a;
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.sp-ai-direct-actions button {
  border-color: #1aad19;
  background: #1aad19;
}

.sp-ai-direct-actions a:hover {
  background: #087565;
}

.sp-ai-direct-actions button:hover {
  background: #148c14;
}

.sp-ai-wechat-qr {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid #d8e8f0;
}

.sp-ai-wechat-qr[hidden] {
  display: none;
}

.sp-ai-wechat-qr img {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
  padding: 5px;
  border: 1px solid #d5e1e9;
  border-radius: 8px;
  background: #fff;
}

.sp-ai-panel.is-contact-required .sp-ai-composer textarea {
  background: #f5f7f9;
  color: #65788a;
}

.sp-ai-quick {
  flex: 0 0 auto;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 14px 10px;
  background: #fff;
  scrollbar-width: none;
}

.sp-ai-quick::-webkit-scrollbar {
  display: none;
}

.sp-ai-quick button {
  flex: 0 0 auto;
  max-width: 220px;
  padding: 7px 10px;
  overflow: hidden;
  border: 1px solid #c9dfeb;
  border-radius: 999px;
  background: #f9fcfd;
  color: #2a566e;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.sp-ai-quick button:hover {
  border-color: var(--sp-blue);
  background: #effbff;
}

.sp-ai-typing {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  padding: 0 17px 9px;
  color: var(--sp-muted);
  font-size: 10.5px;
}

.sp-ai-typing.is-visible {
  display: flex;
}

.sp-ai-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sp-blue);
  animation: sp-ai-dot 900ms ease-in-out infinite;
}

.sp-ai-typing span:nth-child(2) {
  animation-delay: 120ms;
}

.sp-ai-typing span:nth-child(3) {
  animation-delay: 240ms;
}

.sp-ai-typing em {
  margin-left: 3px;
  font-style: normal;
}

@keyframes sp-ai-dot {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.sp-ai-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 8px;
  border-top: 1px solid var(--sp-line);
  background: #fff;
}

.sp-ai-composer textarea {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 118px;
  padding: 10px 11px;
  resize: none;
  border: 1px solid #cbd9e4;
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--sp-ink);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.45;
}

.sp-ai-composer textarea:focus {
  border-color: var(--sp-blue);
  box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.11);
}

.sp-ai-composer textarea::placeholder {
  color: #8b9baa;
}

.sp-ai-send,
.sp-ai-human,
.sp-ai-primary,
.sp-ai-secondary {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.sp-ai-send {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--sp-blue);
  color: #fff;
}

.sp-ai-send:disabled {
  cursor: wait;
  opacity: 0.45;
}

.sp-ai-send svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.sp-ai-human {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 0 8px;
  border-radius: 9px;
  background: #fff6e7;
  color: #9b5d00;
  font-size: 10px;
  font-weight: 700;
}

.sp-ai-human svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.sp-ai-footer {
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  gap: 8px;
  padding: 0 13px 9px;
  background: #fff;
  color: #8393a3;
  font-size: 9.5px;
}

.sp-ai-footer a {
  color: #0879a8;
  text-decoration: none;
}

.sp-ai-lead {
  position: absolute;
  inset: 72px 0 0;
  z-index: 5;
  display: none;
  overflow-y: auto;
  padding: 18px 16px 20px;
  background: #fff;
}

.sp-ai-lead.is-open {
  display: block;
}

.sp-ai-lead-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.sp-ai-lead-head strong {
  color: var(--sp-navy);
  font-size: 17px;
  line-height: 1.25;
}

.sp-ai-lead-head .sp-ai-icon-btn {
  color: var(--sp-navy);
}

.sp-ai-lead > p {
  margin: 0 0 13px;
  color: var(--sp-muted);
  font-size: 11px;
  line-height: 1.45;
}

.sp-ai-lead-form label {
  display: block;
  margin: 0 0 10px;
  color: #34495e;
  font-size: 10.5px;
  font-weight: 700;
}

.sp-ai-lead-form label b {
  color: #cc4a3d;
}

.sp-ai-lead-form input,
.sp-ai-lead-form textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid #cbd9e4;
  border-radius: 8px;
  outline: none;
  background: #fbfdff;
  color: var(--sp-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 400;
}

.sp-ai-lead-form input:focus,
.sp-ai-lead-form textarea:focus {
  border-color: var(--sp-blue);
  box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.1);
}

.sp-ai-lead-form textarea {
  min-height: 86px;
  resize: vertical;
}

.sp-ai-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.sp-ai-form-status {
  min-height: 16px;
  margin: 2px 0 8px;
  color: #53677a;
  font-size: 10.5px;
  line-height: 1.4;
}

.sp-ai-form-status.is-error {
  color: #b63125;
}

.sp-ai-form-status.is-success {
  color: #0b7d54;
}

.sp-ai-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sp-ai-primary,
.sp-ai-secondary {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 750;
}

.sp-ai-primary {
  background: var(--sp-navy);
  color: #fff;
}

.sp-ai-primary:disabled {
  cursor: wait;
  opacity: 0.55;
}

.sp-ai-secondary {
  border: 1px solid #cddbe5;
  background: #fff;
  color: #40566b;
}

@media (max-width: 600px) {
  .sp-ai-launcher {
    right: 16px;
    bottom: 88px;
    min-height: 50px;
    padding-right: 14px;
  }

  .sp-ai-launcher-label {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sp-ai-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    transform: translateY(20px);
  }

  .sp-ai-panel.is-open {
    transform: translateY(0);
  }

  .sp-ai-header {
    min-height: 68px;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .sp-ai-composer {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .sp-ai-notice {
    font-size: 10px;
  }

  .sp-ai-user .sp-ai-bubble,
  .sp-ai-bubble {
    max-width: 91%;
  }
}

@media (max-width: 380px) {
  .sp-ai-form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .sp-ai-human span {
    display: none;
  }

  .sp-ai-human {
    width: 40px;
    justify-content: center;
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sp-ai-panel,
  .sp-ai-launcher,
  .sp-ai-message,
  .sp-ai-typing span {
    animation: none !important;
    transition: none !important;
  }
}
