.kira-chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 3400;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #4f8ef7 0%, #6b5ce7 60%, #9b5de5 100%);
  box-shadow: 0 8px 24px rgba(107, 92, 231, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kira-chat-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 28px rgba(107, 92, 231, 0.5);
}

.kira-chat-fab[aria-expanded="true"] {
  transform: scale(0.95);
}

.kira-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 3500;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 16px;
  animation: kira-chat-fade-in 0.2s ease;
}

.kira-chat-overlay[hidden] {
  display: none !important;
}

@keyframes kira-chat-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes kira-chat-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.kira-chat-panel {
  width: min(400px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 32px));
  background: #fffdf9;
  border: 1px solid #e8dfd3;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: kira-chat-slide-up 0.25s ease;
}

.kira-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid #ebe3d8;
  background: linear-gradient(135deg, rgba(79, 142, 247, 0.08) 0%, rgba(155, 93, 229, 0.08) 100%);
}

.kira-chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f8ef7 0%, #9b5de5 100%);
  color: #fff;
  flex-shrink: 0;
}

.kira-chat-header-text {
  flex: 1;
  min-width: 0;
}

.kira-chat-header-text strong {
  display: block;
  font-size: 0.95rem;
  color: #1a1a2e;
}

.kira-chat-header-text span {
  font-size: 0.78rem;
  color: #64748b;
}

.kira-chat-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.kira-chat-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1a1a2e;
}

.kira-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kira-chat-message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.kira-chat-message-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4f8ef7 0%, #6b5ce7 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.kira-chat-message-assistant {
  align-self: flex-start;
  background: #f5efe6;
  color: #1a1a2e;
  border: 1px solid #ebe3d8;
  border-bottom-left-radius: 4px;
}

.kira-chat-message-error {
  align-self: center;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  font-size: 0.82rem;
  max-width: 100%;
}

.kira-chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #f5efe6;
  border: 1px solid #ebe3d8;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.kira-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9b5de5;
  animation: kira-chat-dot 1.2s infinite ease-in-out;
}

.kira-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.kira-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes kira-chat-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.kira-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #ebe3d8;
  background: #fffdf9;
}

.kira-chat-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid #e8dfd3;
  border-radius: 10px;
  font: inherit;
  font-size: 0.875rem;
  background: #fff;
  color: #1a1a2e;
  resize: none;
  line-height: 1.4;
  max-height: 100px;
}

.kira-chat-input:focus {
  outline: none;
  border-color: #6b5ce7;
  box-shadow: 0 0 0 3px rgba(107, 92, 231, 0.15);
}

.kira-chat-send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #4f8ef7 0%, #6b5ce7 100%);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.kira-chat-send:hover:not(:disabled) {
  transform: scale(1.05);
}

.kira-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .kira-chat-overlay {
    padding: 0;
    align-items: stretch;
  }

  .kira-chat-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: none;
  }

  .kira-chat-fab {
    right: 16px;
    bottom: 16px;
  }
}
