/* AI chat widget. Fixed/overlaid so it never adds to page scroll height. */

.chat-toggle {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 30;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #06120e;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 30px rgba(35, 240, 166, 0.35);
  transition: transform 0.15s ease;
}

.chat-toggle:hover {
  transform: scale(1.05);
}

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

.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + 68px);
  z-index: 30;
  width: min(340px, calc(100vw - 2.5rem));
  height: min(460px, calc(100dvh - 8rem));
  background: #0a0d18;
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
}

.chat-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem;
}

.chat-close:hover {
  color: var(--fg);
}

.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chat-msg {
  max-width: 88%;
  padding: 0.55rem 0.8rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #06120e;
  border-bottom-right-radius: 3px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  border-bottom-left-radius: 3px;
}

.chat-msg a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

.chat-msg.assistant.pending {
  color: var(--fg-muted);
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1 1 auto;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  color: var(--fg);
  font-family: var(--font-body);
  /* 16px minimum -- anything smaller makes iOS Safari auto-zoom the whole
     page on focus, which is what "the page moves" turns out to be. */
  font-size: 16px;
  outline: none;
}

.chat-form input:focus {
  border-color: var(--accent);
}

.chat-form button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #06120e;
  font-size: 1rem;
  cursor: pointer;
  flex: 0 0 auto;
}

@media (max-width: 420px) {
  .chat-panel {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
  }
  .chat-toggle {
    right: 0.9rem;
    bottom: 0.9rem;
  }
}
