#agent-chat-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 16px;
  pointer-events: none;
}

#agent-chat-root *, #agent-chat-root *::before, #agent-chat-root *::after {
  box-sizing: border-box;
}

.ac-launcher {
  pointer-events: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(99, 102, 241, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ac-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 18px 34px rgba(99, 102, 241, 0.4);
}

.ac-launcher:active {
  transform: scale(0.97);
}

.ac-launcher .material-icons {
  font-size: 24px;
}

.ac-panel {
  pointer-events: auto;
  width: 360px;
  max-width: min(92vw, 360px);
  height: 560px;
  max-height: 70vh;
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.4));
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
}

.ac-panel[hidden] {
  display: none;
}

.ac-header {
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ac-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ac-avatar {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ac-title {
  font-size: 14px;
  font-weight: 600;
}

.ac-subtitle {
  font-size: 11px;
  opacity: 0.85;
}

.ac-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ac-clear {
  font-size: 12px;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.ac-clear:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.ac-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.ac-close .material-icons {
  font-size: 22px;
}

.ac-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.ac-scroll::-webkit-scrollbar {
  width: 8px;
}

.ac-scroll::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 9999px;
}

.ac-scroll::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.65);
  border-radius: 9999px;
}

.ac-empty {
  text-align: center;
  color: #475569;
  font-size: 14px;
  margin-top: 14px;
}

.ac-message-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.ac-message-row.ac-role-user {
  justify-content: flex-end;
}

.ac-message-row.ac-role-assistant,
.ac-message-row.ac-role-system {
  justify-content: flex-start;
}

.ac-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ac-bubble-user {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
}

.ac-bubble-assistant {
  background: rgba(255, 255, 255, 0.7);
  color: #0f172a;
  backdrop-filter: blur(6px);
}

.ac-bubble-system {
  background: rgba(245, 158, 11, 0.15);
  color: #92400e;
}

.ac-avatar-bubble {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.ac-role-assistant .ac-avatar-bubble {
  background: linear-gradient(135deg, #10b981, #14b8a6);
  color: #fff;
}

.ac-role-system .ac-avatar-bubble {
  background: #9ca3af;
  color: #fff;
}

.ac-role-user .ac-avatar-bubble {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
}

.ac-markdown h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 10px 0;
}

.ac-markdown p {
  margin: 6px 0;
}

.ac-markdown ul,
.ac-markdown ol {
  padding-left: 18px;
  margin: 6px 0;
}

.ac-markdown li {
  margin-bottom: 4px;
}

.ac-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #475569;
}

.ac-typing[hidden] {
  display: none;
}

.ac-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: #6366f1;
  animation: ac-bounce 1s infinite;
}

.ac-dot:nth-child(2) {
  background: #a855f7;
  animation-delay: 0.15s;
}

.ac-dot:nth-child(3) {
  background: #ec4899;
  animation-delay: 0.3s;
}

.ac-error {
  margin: 4px 16px 0;
  font-size: 12px;
  color: #dc2626;
}

.ac-error[hidden] {
  display: none;
}

.ac-form {
  padding: 12px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ac-input {
  flex: 1;
  resize: none;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  outline: none;
  background: rgba(255, 255, 255, 0.85);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 40px;
  max-height: 140px;
}

.ac-input:focus {
  border-color: rgba(99, 102, 241, 0.7);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ac-send {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(99, 102, 241, 0.35);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ac-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ac-send:not(:disabled):active {
  transform: scale(0.95);
}

.ac-send .material-icons {
  font-size: 20px;
}

@keyframes ac-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20%);
  }
}

@media (max-width: 640px) {
  #agent-chat-root {
    bottom: calc(16px + env(safe-area-inset-bottom, 0));
    right: calc(16px + env(safe-area-inset-right, 0));
    gap: 12px;
  }

  .ac-panel {
    width: min(340px, 100vw - 32px);
    max-height: 70vh;
  }
}

@media (max-width: 480px) {
  .ac-panel {
    width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
  }
}

.ac-input::-webkit-outer-spin-button,
.ac-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ac-input[type=number] {
  -moz-appearance: textfield;
}
