:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1a1c20;
  --text-muted: #6b7280;
  --border: #e2e4e9;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --ai-bubble: #ffffff;
  --user-bubble: #4f46e5;
  --user-bubble-text: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --radius: 14px;
  --error: #dc2626;
}

[data-theme="dark"] {
  --bg: #14151a;
  --surface: #1c1e24;
  --surface-2: #24262e;
  --text: #f1f2f4;
  --text-muted: #9aa0aa;
  --border: #2e313a;
  --accent: #6366f1;
  --accent-hover: #7c7ff0;
  --ai-bubble: #24262e;
  --user-bubble: #6366f1;
  --user-bubble-text: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--border); }

.user-menu-placeholder {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.chat-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 24px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 68px);
}

.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 4px 20px;
  overflow-y: auto;
}

.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 100%;
  animation: fadeIn 0.2s ease;
}

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

.message-user {
  flex-direction: row-reverse;
}

.avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.avatar-ai { background: var(--accent); }
.avatar-user { background: #10b981; }

.bubble {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  line-height: 1.5;
  max-width: 75%;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border: none;
}

.bubble.error-bubble {
  background: #fee2e2;
  color: var(--error);
  border-color: #fecaca;
}
[data-theme="dark"] .bubble.error-bubble {
  background: #3b1e1e;
  color: #f87171;
  border-color: #5c2b2b;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 4px 12px;
}

.quick-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.quick-btn:hover { background: var(--border); }
.quick-btn:active { transform: scale(0.97); }

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
}

#chat-input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  max-height: 140px;
  padding: 8px;
}

.send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.disclaimer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 10px 0 0;
}

@media (max-width: 600px) {
  .bubble { max-width: 85%; }
  .chat-container { padding: 10px 10px 16px; }
}
