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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-2: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #d4a574;
  --accent-dim: rgba(212, 165, 116, 0.1);
  --user-bg: #2a2520;
  --assistant-bg: #1a1a1a;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 15, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}

.logo h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.btn-new-chat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

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

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 16px;
}

.welcome-icon {
  color: var(--accent);
  opacity: 0.6;
}

.welcome h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.welcome p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.suggestion {
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

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

.welcome.hidden {
  display: none;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  animation: fadeIn 0.3s ease;
}

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

.message.user {
  background: var(--user-bg);
  border: 1px solid rgba(212, 165, 116, 0.15);
}

.message.assistant {
  background: var(--assistant-bg);
  border: 1px solid var(--border);
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.message.user .message-avatar {
  background: var(--accent);
  color: #1a1a1a;
}

.message.assistant .message-avatar {
  background: var(--surface-2);
  color: var(--accent);
  border: 1px solid var(--border);
}

.message-content {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.message-content pre {
  background: #0a0a0a;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.message-content code {
  background: #0a0a0a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-content p {
  margin: 6px 0;
}

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

.message-content ul, .message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 4px 0;
}

.message-content h1, .message-content h2, .message-content h3 {
  margin: 12px 0 6px;
  color: var(--accent);
}

.message-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-muted);
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

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

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

.input-area {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  background: rgba(15, 15, 15, 0.85);
  backdrop-filter: blur(12px);
}

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

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

#messageInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 150px;
  padding: 6px 0;
}

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

.btn-send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #1a1a1a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-send:not(:disabled):hover {
  filter: brightness(1.1);
  transform: scale(1.05);
}

.disclaimer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  opacity: 0.6;
}

@media (max-width: 640px) {
  .header-inner { padding: 10px 14px; }
  .chat-container { padding: 14px; }
  .input-area { padding: 12px 14px 16px; }
  .message { padding: 12px; }
  .suggestions { flex-direction: column; }
  .logo h1 { font-size: 0.95rem; }
  .btn-new-chat span { display: none; }
}
