#chat .ai-panel {
  margin: 0 16px 8px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

#chat .ai-panel p {
  font-size: 0.78rem;
  line-height: 1.6;
  margin: 0 0 10px;
  color: var(--muted);
}

#chat .ai-panel button {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

#chat #ai-start {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

#chat #ai-start:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

#chat .ai-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#chat #ai-status {
  display: block;
  font-size: 0.76rem;
  line-height: 1.55;
  margin-top: 10px;
  color: var(--ink);
}

#chat #ai-progress {
  display: block;
  width: 100%;
  height: 8px;
  margin-top: 10px;
  accent-color: var(--accent);
}

#chat button:disabled {
  opacity: 0.6;
  cursor: wait;
}

#chat .ai-sources {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  line-height: 1.6;
  margin-top: 10px;
}

#chat .ai-sources a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

#chat #chat-log {
  max-height: 220px;
}

#chat .ai-panel a {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 480px) {
  #chat {
    max-height: calc(100dvh - 96px);
  }
  #chat #chat-log {
    max-height: 180px;
  }
  #chat .ai-actions button {
    width: 100%;
  }
}

#chat .chat-head {
  position: sticky;
  top: 0;
  z-index: 2;
}
