/* ---------- AI chat widget ----------
   Bottom-right (the daily-song player owns bottom-left). Built from the same
   tokens as the rest of the site so it doesn't look like a bolted-on widget. */

.ai-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  font-family: var(--font);
}

.ai-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--dark);
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.ai-chat-toggle:hover { transform: scale(1.06); }
.ai-chat-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

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

.ai-chat-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: min(340px, calc(100vw - 40px));
  max-height: min(480px, calc(100vh - 120px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.ai-chat-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.ai-chat-close:hover { color: var(--text); }

.ai-chat-messages {
  flex: 1;
  min-height: 160px;
  max-height: 340px;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-chat-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--dark);
}
.ai-chat-msg-assistant {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.ai-chat-msg-pending::after {
  content: "▍";
  opacity: 0.6;
  animation: ai-chat-blink 1s step-end infinite;
}
@keyframes ai-chat-blink {
  50% { opacity: 0; }
}

.ai-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ai-chat-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 0.92rem;
}
.ai-chat-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ai-chat-input:disabled { opacity: 0.6; }

.ai-chat-send {
  width: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--dark);
  cursor: pointer;
  font-size: 1rem;
}
.ai-chat-send:hover { background: var(--accent-dark); }

@media (prefers-reduced-motion: reduce) {
  .ai-chat-toggle { transition: none; }
  .ai-chat-msg-pending::after { animation: none; }
}

@media (max-width: 480px) {
  .ai-chat { right: 12px; bottom: 12px; }
  .ai-chat-panel { bottom: 64px; }
}
