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

:root {
  --accent: #1e40af;
  --accent-light: #3b82f6;
  --accent-bg: #eff6ff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  color: white;
  padding: 0 24px;
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  max-width: 800px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
  color: white;
  flex-shrink: 0;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 2px;
  font-weight: 400;
}

.header-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 5px 10px;
  border-radius: 6px;
  color: #cbd5e1;
}

/* ── Chat Area ── */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.chat::-webkit-scrollbar {
  width: 6px;
}

.chat::-webkit-scrollbar-track {
  background: transparent;
}

.chat::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* ── Messages ── */
.message {
  display: flex;
  gap: 12px;
  max-width: 90%;
  animation: fadeIn 0.3s ease;
}

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

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

.message.assistant {
  align-self: flex-start;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
  letter-spacing: 0.3px;
}

.message.user .avatar {
  background: linear-gradient(135deg, var(--accent), #1e40af);
}

.bubble {
  padding: 14px 18px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 0.9rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user .bubble {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: white;
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.message.assistant .bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* ── Welcome message specifics ── */
.topic-list {
  margin: 10px 0;
  padding-left: 0;
  list-style: none;
}

.topic-list li {
  padding: 4px 0 4px 20px;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.topic-list li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-light);
}

.welcome-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Markdown inside assistant bubbles ── */
.message.assistant .bubble h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 18px 0 8px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.message.assistant .bubble h2:first-child {
  margin-top: 2px;
}

.message.assistant .bubble h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--text);
}

.message.assistant .bubble p {
  margin: 8px 0;
}

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

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

.message.assistant .bubble ul,
.message.assistant .bubble ol {
  margin: 8px 0;
  padding-left: 22px;
}

.message.assistant .bubble li {
  margin: 5px 0;
}

.message.assistant .bubble strong {
  font-weight: 600;
  color: var(--text);
}

.message.assistant .bubble blockquote {
  border-left: 3px solid var(--accent-light);
  padding: 8px 14px;
  margin: 10px 0;
  background: var(--accent-bg);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.message.assistant .bubble a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.message.assistant .bubble a:hover {
  border-bottom-color: var(--accent-light);
}

.message.user .bubble a {
  color: #bfdbfe;
}

/* ── Thinking / Loading ── */
.thinking {
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 8px;
}

.thinking::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Input Area ── */
.input-area {
  padding: 16px 24px 20px;
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

#question {
  flex: 1;
  padding: 14px 18px;
  border: none;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: transparent;
  color: var(--text);
}

#question::placeholder {
  color: var(--text-muted);
}

#send-btn {
  padding: 10px 16px;
  background: transparent;
  color: var(--accent-light);
  border: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 12px 12px 0;
}

#send-btn:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

#send-btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

#send-btn:disabled:hover {
  background: transparent;
}

.input-hint {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Error state ── */
.error-text {
  color: #dc2626;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .header-inner {
    padding: 16px 0;
  }

  .header-badge {
    display: none;
  }

  header h1 {
    font-size: 1.1rem;
  }

  .chat {
    padding: 16px 16px 8px;
  }

  .input-area {
    padding: 12px 16px 16px;
  }

  .message {
    max-width: 95%;
  }

  .avatar {
    width: 28px;
    height: 28px;
    font-size: 0.6rem;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
  }
}
