#pw-chat-widget-root {
  --pw-chat-primary: #19995d;
  --pw-chat-bg: #ffffff;
  --pw-chat-text: #1f2937;
  --pw-chat-muted: #6b7280;
  --pw-chat-border: #d1d5db;
  --pw-chat-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 99999;
  font-family: "Open Sans", Arial, sans-serif;
  overflow-x: hidden;
  pointer-events: none;
}

#pw-chat-widget-root,
#pw-chat-widget-root * {
  box-sizing: border-box;
}

.pw-chat-toggle {
  border: 0;
  border-radius: 999px;
  background: var(--pw-chat-primary);
  color: #fff;
  min-height: 52px;
  padding: 10px 18px;
  box-shadow: var(--pw-chat-shadow);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  pointer-events: auto;
}

.pw-chat-panel {
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 540px;
  max-height: calc(100vh - 92px);
  background: var(--pw-chat-bg);
  border: 1px solid var(--pw-chat-border);
  border-radius: 16px;
  box-shadow: var(--pw-chat-shadow);
  display: none;
  overflow: hidden;
  overflow-x: hidden;
  pointer-events: auto;
}

.pw-chat-panel.is-open {
  display: flex;
  flex-direction: column;
}

.pw-chat-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--pw-chat-border);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pw-chat-title {
  color: var(--pw-chat-text);
  font-size: 16px;
  font-weight: 700;
}

.pw-chat-actions {
  display: flex;
  gap: 8px;
}

.pw-chat-icon-btn {
  border: 1px solid var(--pw-chat-border);
  background: #fff;
  border-radius: 10px;
  width: 32px;
  height: 32px;
  line-height: 30px;
  text-align: center;
  font-size: 16px;
  cursor: pointer;
}

.pw-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #fff;
}

.pw-chat-msg {
  margin-bottom: 10px;
  max-width: 88%;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.pw-chat-msg-user {
  margin-left: auto;
  background: #dcfce7;
  color: #14532d;
}

.pw-chat-msg-assistant {
  margin-right: auto;
  background: #f3f4f6;
  color: #111827;
}

.pw-chat-typing-msg {
  min-width: 72px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pw-chat-typing-text {
  font-size: 13px;
  color: #475569;
  margin-right: 2px;
}

.pw-chat-typing-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 3px;
  border-radius: 50%;
  background: #94a3b8;
  animation: pwChatTypingBlink 1.1s infinite ease-in-out;
}

.pw-chat-typing-dot:last-child {
  margin-right: 0;
}

.pw-chat-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.pw-chat-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pwChatTypingBlink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.pw-chat-meta {
  color: var(--pw-chat-muted);
  font-size: 12px;
  margin: 4px 2px 10px;
}

.pw-chat-system {
  border-top: 1px solid var(--pw-chat-border);
  border-bottom: 1px solid var(--pw-chat-border);
  background: #f8fafc;
}

.pw-chat-system summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 12px;
  color: #334155;
  font-weight: 700;
  list-style: none;
}

.pw-chat-system summary::-webkit-details-marker {
  display: none;
}

.pw-chat-system-list {
  margin: 0;
  padding: 0 12px 10px 24px;
  max-height: 120px;
  overflow-y: auto;
}

.pw-chat-system-item,
.pw-chat-system-empty {
  color: #475569;
  font-size: 12px;
  margin: 0 0 4px;
}

.pw-chat-quick {
  border-top: 1px solid var(--pw-chat-border);
  padding: 10px 12px 8px;
  display: block;
  background: #f8fafc;
}

.pw-chat-chip {
  border: 1px solid #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: left;
  margin: 0 0 8px;
}

.pw-chat-chip:last-child {
  margin-bottom: 0;
}

.pw-chat-form {
  border-top: 1px solid var(--pw-chat-border);
  padding: 10px;
  background: #fff;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.pw-chat-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  max-height: 140px;
  resize: vertical;
  border: 1px solid var(--pw-chat-border);
  border-radius: 10px;
  padding: 10px;
  font-size: 16px;
  color: var(--pw-chat-text);
}

.pw-chat-send {
  border: 0;
  border-radius: 10px;
  min-width: 78px;
  background: var(--pw-chat-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
}

.pw-chat-send[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
}

.pw-chat-hidden {
  display: none !important;
}

@media (max-width: 1024px) {
  #pw-chat-widget-root {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
  }

  .pw-chat-toggle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: auto;
    border-radius: 999px;
  }

  #pw-chat-widget-root.pw-chat-open .pw-chat-toggle {
    display: none;
  }

  .pw-chat-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 14px;
  }

  .pw-chat-input {
    line-height: 1.35;
    resize: none;
  }
}
