:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --text: #1e293b;
  --muted: #64748b;
  --bot-bg: #e2e8f0;
  --user-bg: #2563eb;
  --user-text: #ffffff;
  --border: #cbd5e1;
  --radius: 12px;
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.chat {
  width: 100%;
  max-width: 720px;
  height: min(90vh, 720px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: #fff;
}

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

.chat-header p {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-top: 4px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.bot {
  align-self: flex-start;
  background: var(--bot-bg);
  border-bottom-left-radius: 4px;
}

.message.user {
  align-self: flex-end;
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.message.error {
  background: #fee2e2;
  color: #991b1b;
}

.typing {
  color: var(--muted);
  font-style: italic;
}

.controls {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.mode-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.input-row {
  display: flex;
  gap: 8px;
}

#message-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  font-family: inherit;
}

#message-input:focus {
  border-color: var(--primary);
}

#send-btn {
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

#send-btn:hover:not(:disabled) {
  background: var(--primary-hover);
}

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