:root {
  --primary-color: #f6821f;
  --primary-hover: #e67e22;
  --light-bg: #f9fafb;
  --dark-bg: #1e1e1e;
  --border-color: #e5e7eb;
  --text-color: #1f2937;
  --text-light: #6b7280;
  --user-msg-bg: #fff2e6;
  --assistant-msg-bg: #f3f4f6;
  --dark-user-bg: #2c2c2c;
  --dark-assistant-bg: #333;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-stack);
  background-color: var(--light-bg);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  max-width: 800px;
  margin-inline: auto;
  height: 100vh;
}

body.dark {
  background-color: var(--dark-bg);
  color: #f9f9f9;
}

header {
  text-align: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

#theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--primary-color);
}

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  margin: 1rem;
}

.chat-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  background: var(--light-bg);
}

body.dark .chat-messages {
  background: #1a1a1a;
}

.message {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.message .avatar {
  margin-right: 0.75rem;
  font-size: 1.3rem;
}

.message .content {
  background: var(--assistant-msg-bg);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  max-width: 80%;
  word-wrap: break-word;
}

.user-message .content {
  background: var(--user-msg-bg);
  margin-left: auto;
}

body.dark .assistant-message .content {
  background: var(--dark-assistant-bg);
  color: #f0f0f0;
}

body.dark .user-message .content {
  background: var(--dark-user-bg);
  color: #f0f0f0;
}

.typing-indicator {
  font-style: italic;
  color: var(--text-light);
  margin: 0.5rem 1rem;
  display: none;
}

.typing-indicator.visible {
  display: block;
}

.message-input {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-top: 1px solid var(--border-color);
  background: white;
  gap: 0.5rem;
}

body.dark .message-input {
  background: #2c2c2c;
}

textarea {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem;
  font-family: inherit;
  resize: none;
  font-size: 1rem;
  min-height: 38px;
  background: white;
  color: var(--text-color);
}

body.dark textarea {
  background: #1a1a1a;
  color: #f0f0f0;
}

button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s;
}

button:hover {
  background-color: var(--primary-hover);
}

button:disabled {
  background-color: var(--text-light);
  cursor: not-allowed;
}

#mic-button {
  background-color: transparent;
  color: var(--primary-color);
}

#mic-button.listening {
  animation: pulse 1s infinite;
  color: red;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

#scroll-button {
  position: fixed;
  bottom: 80px;
  right: 30px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  padding: 0.7rem;
  font-size: 1.2rem;
  display: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

#scroll-button.show {
  display: block;
}

footer {
  text-align: center;
  padding: 0.8rem;
  font-size: 0.85rem;
  color: var(--text-light);
}
