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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3147;
  --accent: #6c63ff;
  --accent-dim: rgba(108, 99, 255, 0.15);
  --text: #e8eaf0;
  --text-dim: #7b82a0;
  --user-bg: #6c63ff;
  --ai-bg: #1a1d27;
  --radius: 16px;
  --font: 'Inter', system-ui, sans-serif;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 860px;
  margin: 0 auto;
}

/* Header */
.header {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
}

.logo-icon { font-size: 20px; }

.header-meta {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
}

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

.chat-window::-webkit-scrollbar { width: 6px; }
.chat-window::-webkit-scrollbar-track { background: transparent; }
.chat-window::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Welcome screen */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  gap: 16px;
  padding: 40px 20px;
}

.welcome-icon { font-size: 48px; }

.welcome h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.welcome-desc {
  color: var(--text-dim);
  max-width: 460px;
  font-size: 15px;
}

.welcome-desc strong {
  color: var(--text);
}

.welcome-hint {
  color: var(--text-dim);
  font-size: 13px;
  max-width: 420px;
  margin-top: 4px;
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
  max-width: 480px;
}

.suggestion {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.suggestion:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Messages */
.message {
  display: flex;
  gap: 12px;
  animation: fadeIn 0.2s ease;
}

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

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

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.user .avatar { background: var(--user-bg); }
.message.ai .avatar   { background: var(--surface2); border: 1px solid var(--border); }

.bubble {
  max-width: 72%;
  padding: 14px 18px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 15px;
}

.message.user .bubble {
  background: var(--user-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.ai .bubble {
  background: var(--ai-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  white-space: pre-wrap;
}

/* Typing indicator */
.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 16px 18px;
}

.typing span {
  width: 7px;
  height: 7px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.status-text {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  padding: 4px 0;
}

/* Input area */
.input-area {
  border-top: 1px solid var(--border);
  padding: 16px 24px 20px;
  flex-shrink: 0;
}

.input-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px 10px 16px;
  transition: border-color 0.15s;
}

.input-inner:focus-within { border-color: var(--accent); }

.message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 160px;
  outline: none;
}

.message-input::placeholder { color: var(--text-dim); }

.send-btn {
  width: 38px;
  height: 38px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}

.send-btn:hover  { opacity: 0.85; }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Input footer */
.input-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
}

.input-footer a {
  color: var(--accent);
  text-decoration: none;
}

.input-footer a:hover {
  text-decoration: underline;
}

/* Error */
.error-bubble {
  background: rgba(255, 80, 80, 0.1);
  border: 1px solid rgba(255, 80, 80, 0.3);
  color: #ff8080;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
}

/* Header right group */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* New Chat button */
.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.new-chat-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* Topic pills */
.topic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 4px 0 8px;
}

.pill {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
