/* KartiTaro — AI tarologist unified chat (v2). Love-tarot only. */

.ai-chat-v2 {
  align-items: flex-end;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 0;
  position: fixed;
  z-index: 1200;
}

.ai-chat-v2[hidden] {
  display: none !important;
}

body.ai-chat-v2-open {
  overflow: hidden;
}

.ai-chat-v2-backdrop {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: rgba(4, 6, 18, 0.72);
  inset: 0;
  position: absolute;
}

.ai-chat-v2-panel {
  background: linear-gradient(175deg, #14102a 0%, #080a18 100%);
  border: 1px solid rgba(186, 128, 255, 0.28);
  border-radius: 20px 20px 0 0;
  box-shadow:
    0 -8px 48px rgba(0, 0, 0, 0.35),
    0 0 40px rgba(151, 61, 255, 0.1);
  display: flex;
  flex-direction: column;
  height: min(92dvh, 720px);
  max-width: 480px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.ai-chat-v2-header {
  align-items: center;
  background: rgba(12, 10, 26, 0.92);
  border-bottom: 1px solid rgba(186, 128, 255, 0.18);
  display: flex;
  flex-shrink: 0;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px 12px;
}

.ai-chat-v2-header-main {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.ai-chat-v2-avatar {
  align-items: center;
  background: linear-gradient(145deg, rgba(38, 219, 255, 0.18), rgba(186, 128, 255, 0.28));
  border: 1px solid rgba(186, 128, 255, 0.35);
  border-radius: 50%;
  display: flex;
  flex-shrink: 0;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.ai-chat-v2-avatar svg {
  color: rgba(255, 255, 255, 0.92);
  height: 22px;
  width: 22px;
}

.ai-chat-v2-title {
  color: #fff;
  font-family: Lora, serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}

.ai-chat-v2-presence {
  color: rgba(38, 219, 255, 0.85);
  font-family: Montserrat, sans-serif;
  font-size: 12px;
  line-height: 1.3;
  margin: 2px 0 0;
}

.ai-chat-v2-close {
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 26px;
  line-height: 1;
  padding: 4px 8px;
  transition: background 0.2s ease, color 0.2s ease;
}

.ai-chat-v2-close:hover {
  background: rgba(186, 128, 255, 0.14);
  color: #fff;
}

.ai-chat-v2-thread {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ai-chat-v2-messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 8px;
  scrollbar-color: rgba(186, 128, 255, 0.4) transparent;
  scrollbar-width: thin;
}

.ai-chat-v2-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-v2-messages::-webkit-scrollbar-thumb {
  background: rgba(186, 128, 255, 0.4);
  border-radius: 6px;
}

.ai-chat-v2-msg {
  display: flex;
  max-width: 100%;
}

.ai-chat-v2-msg--user {
  justify-content: flex-end;
}

.ai-chat-v2-msg--assistant {
  justify-content: flex-start;
}

.ai-chat-v2-bubble {
  border-radius: 18px;
  font-family: Montserrat, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  max-width: min(88%, 340px);
  padding: 10px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-chat-v2-msg--user .ai-chat-v2-bubble {
  background: linear-gradient(135deg, rgba(38, 219, 255, 0.2), rgba(186, 128, 255, 0.32));
  border-bottom-right-radius: 6px;
  border: 1px solid rgba(186, 128, 255, 0.32);
  color: #f8f6ff;
}

.ai-chat-v2-msg--assistant .ai-chat-v2-bubble {
  background: rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 6px;
  border: 1px solid rgba(186, 128, 255, 0.16);
  color: rgba(255, 255, 255, 0.94);
}

.ai-chat-v2-msg--welcome .ai-chat-v2-bubble {
  border-left: 3px solid rgba(38, 219, 255, 0.6);
  max-width: min(94%, 380px);
}

.ai-chat-v2-msg--typing .ai-chat-v2-bubble {
  padding: 12px 16px;
}

.ai-chat-v2-typing-dots {
  display: inline-flex;
  gap: 5px;
}

.ai-chat-v2-typing-dots span {
  animation: ai-chat-v2-dot 1.2s ease-in-out infinite;
  background: rgba(186, 128, 255, 0.85);
  border-radius: 50%;
  display: block;
  height: 7px;
  width: 7px;
}

.ai-chat-v2-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-chat-v2-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ai-chat-v2-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.ai-chat-v2-consent {
  flex-shrink: 0;
  margin: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}

.ai-chat-v2-footer {
  background: rgba(10, 8, 22, 0.96);
  border-top: 1px solid rgba(186, 128, 255, 0.16);
  flex-shrink: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0));
}

.ai-chat-v2-compose {
  margin: 0;
}

.ai-chat-v2-compose-row {
  align-items: flex-end;
  background: rgba(22, 18, 42, 0.95);
  border: 1px solid rgba(186, 128, 255, 0.28);
  border-radius: 22px;
  display: flex;
  gap: 6px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-chat-v2-compose-row:focus-within {
  border-color: rgba(186, 128, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(38, 219, 255, 0.12);
}

.ai-chat-v2-input {
  appearance: none;
  background: transparent;
  border: 0;
  color: #f5f3ff;
  flex: 1 1 auto;
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  max-height: 120px;
  min-height: 24px;
  outline: none;
  padding: 6px 0;
  resize: none;
  width: 100%;
}

.ai-chat-v2-input::placeholder {
  color: rgba(255, 255, 255, 0.38);
}

.ai-chat-v2-input:disabled {
  opacity: 0.5;
}

.ai-chat-v2-send {
  align-items: center;
  appearance: none;
  background: linear-gradient(135deg, rgba(38, 219, 255, 0.85), rgba(186, 128, 255, 0.9));
  border: 0;
  border-radius: 50%;
  color: #0a0816;
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 40px;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.15s ease;
  width: 40px;
}

.ai-chat-v2-send:hover:not(:disabled) {
  transform: scale(1.04);
}

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

.ai-chat-v2-send svg {
  height: 18px;
  width: 18px;
}

.ai-chat-v2-status {
  color: rgba(255, 255, 255, 0.55);
  font-family: Montserrat, sans-serif;
  font-size: 12px;
  margin: 6px 4px 0;
  min-height: 16px;
  text-align: center;
}

.ai-chat-v2-status.is-error {
  color: #ff9b9b;
}

@media screen and (min-width: 768px) {
  .ai-chat-v2 {
    align-items: center;
    padding: 24px 16px;
  }

  .ai-chat-v2-panel {
    border-radius: 20px;
    height: min(82vh, 680px);
  }
}
