:root {
  --waicc-ink: #0a1530;
  --waicc-muted: #4a5e87;
  --waicc-line: #dbe8ff;
  --waicc-surface: #ffffff;
  --waicc-blue: #4763f6;
  --waicc-cyan: #00c2ff;
  --waicc-navy: #0b2a6f;
  --waicc-user: #e8fff8;
  --waicc-assistant: #f3f7ff;
  --waicc-shadow: 0 18px 48px rgba(34, 80, 200, 0.18);
  --waicc-grad: linear-gradient(135deg, var(--waicc-blue), var(--waicc-cyan));
}

.waicc-root {
  position: fixed;
  right: 20px;
  bottom: 18px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.waicc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 15px 18px;
  background: var(--waicc-grad);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 14px 34px rgba(24, 86, 225, 0.35);
  cursor: pointer;
}

.waicc-toggle__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  animation: waiccPulse 1.8s infinite;
}

.waicc-panel {
  width: min(420px, calc(100vw - 24px));
  border-radius: 24px;
  border: 1px solid rgba(219, 232, 255, 0.85);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 249, 255, 0.98));
  box-shadow: var(--waicc-shadow);
  overflow: hidden;
  backdrop-filter: blur(8px);
}

.waicc-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 14px;
  color: #fff;
  background:
    radial-gradient(circle at top right, rgba(96, 210, 255, 0.38), transparent 42%),
    linear-gradient(135deg, #113c97, #4763f6 55%, #00bff2);
}

.waicc-panel__title {
  display: block;
  font-size: 18px;
}

.waicc-panel__subtitle {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
}

.waicc-panel__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.waicc-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.waicc-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  padding: 18px;
  overflow-y: auto;
  background:
    radial-gradient(circle at top left, rgba(71, 99, 246, 0.08), transparent 30%),
    radial-gradient(circle at bottom right, rgba(0, 194, 255, 0.1), transparent 28%),
    #f9fbff;
}

.waicc-message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 90%;
}

.waicc-message--assistant {
  align-self: flex-start;
}

.waicc-message--user {
  align-self: flex-end;
}

.waicc-message__meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--waicc-muted);
}

.waicc-message__bubble {
  border-radius: 18px;
  padding: 14px 15px;
  color: var(--waicc-ink);
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid var(--waicc-line);
  box-shadow: 0 8px 18px rgba(20, 55, 128, 0.06);
}

.waicc-message--assistant .waicc-message__bubble {
  background: var(--waicc-assistant);
  border-top-left-radius: 6px;
}

.waicc-message--user .waicc-message__bubble {
  background: var(--waicc-user);
  border-top-right-radius: 6px;
}

.waicc-message__bubble--typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.waicc-message__bubble--typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6a8cff;
  animation: waiccTyping 1.2s infinite ease-in-out;
}

.waicc-message__bubble--typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.waicc-message__bubble--typing span:nth-child(3) {
  animation-delay: 0.3s;
}

.waicc-form {
  padding: 16px 18px 18px;
  background: #fff;
  border-top: 1px solid rgba(219, 232, 255, 0.95);
}

.waicc-handoff {
  display: grid;
  gap: 10px;
  padding: 14px 18px 0;
  background: #fff;
}

.waicc-handoff[hidden] {
  display: none !important;
}

.waicc-handoff__text {
  margin: 0;
  color: var(--waicc-muted);
  font-size: 13px;
  line-height: 1.45;
}

.waicc-handoff__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1ea952, #25d366);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(37, 211, 102, 0.24);
}

.waicc-handoff__button:hover {
  color: #fff;
  text-decoration: none;
}

.waicc-form textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--waicc-line);
  border-radius: 16px;
  background: #f8fbff;
  padding: 14px;
  font: inherit;
  color: var(--waicc-ink);
}

.waicc-form textarea:focus {
  outline: 2px solid rgba(71, 99, 246, 0.18);
  border-color: rgba(71, 99, 246, 0.45);
}

.waicc-form__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.waicc-note {
  display: block;
  color: var(--waicc-muted);
  font-size: 12px;
  line-height: 1.45;
}

.waicc-submit {
  flex-shrink: 0;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  background: var(--waicc-grad);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes waiccPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.75);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

@keyframes waiccTyping {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.55;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .waicc-root {
    right: 12px;
    left: auto;
    bottom: 12px;
    align-items: flex-end;
  }

  .waicc-toggle {
    justify-content: center;
    width: auto;
    min-width: 146px;
    height: 54px;
    padding: 0 14px;
    border-radius: 999px;
    gap: 8px;
  }

  .waicc-toggle::before {
    content: "💬";
    font-size: 18px;
    line-height: 1;
  }

  .waicc-toggle__dot {
    display: none;
  }

  .waicc-toggle__label {
    display: block;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
  }

  .waicc-panel {
    width: min(360px, calc(100vw - 20px));
    max-height: min(78vh, 640px);
  }

  .waicc-messages {
    max-height: calc(78vh - 220px);
  }

  .waicc-form__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .waicc-submit {
    width: 100%;
  }
}
