* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f5f5;
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 800px;
  margin: 0 auto;
  background: white;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.user-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-input-group label {
  font-size: 0.9rem;
}

.user-input-group input {
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  width: 120px;
}

.topic-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.topic-selector label {
  font-size: 0.9rem;
}

.topic-selector select {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
}

.topic-selector select:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Chat Container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #fafafa;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.welcome-message {
  text-align: center;
  color: #666;
  padding: 2rem;
}

.welcome-message p {
  margin: 0.5rem 0;
}

/* Message Bubbles */
.message {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  background: #667eea;
  color: white;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message.assistant p {
  margin: 0.5rem 0;
}

.message.assistant p:first-child {
  margin-top: 0;
}

.message.assistant p:last-child {
  margin-bottom: 0;
}

/* Loading indicator */
.message.loading {
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #667eea;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Area */
.input-area {
  padding: 1rem;
  background: white;
  border-top: 1px solid #eee;
}

#chat-form {
  display: flex;
  gap: 0.5rem;
}

#user-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 24px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#user-input:focus {
  border-color: #667eea;
}

#user-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

#send-btn {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

#send-btn:hover:not(:disabled) {
  opacity: 0.9;
}

#send-btn:active:not(:disabled) {
  transform: scale(0.98);
}

#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 600px) {
  .header {
    padding: 0.75rem;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .message {
    max-width: 90%;
  }

  #send-btn {
    padding: 0.75rem 1rem;
  }
}
