:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242836;
  --border: #2e3347;
  --text: #e4e6f0;
  --text-dim: #8b8fa3;
  --accent: #3b82f6;
  --accent-soft: #1e3a5f;
  --bot-bubble: #1e293b;
  --user-bubble: #1d4ed8;
  --success: #22c55e;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
}

header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

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

.subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.categories {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.categories::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cat-btn:hover, .cat-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.cat-btn .count {
  color: var(--text-dim);
  font-size: 0.7rem;
  margin-left: 4px;
}

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

.message {
  display: flex;
  max-width: 85%;
}

.message.bot { align-self: flex-start; }
.message.user { align-self: flex-end; }

.bubble {
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.9rem;
  word-break: break-word;
}

.bot .bubble {
  background: var(--bot-bubble);
  border-bottom-left-radius: 4px;
}

.user .bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}

.bubble strong { color: var(--accent); }
.bubble em { color: var(--text-dim); font-style: normal; }

.bubble pre {
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.4;
}

.loading {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.loading span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading span:nth-child(1) { animation-delay: -0.32s; }
.loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.ds-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.ds-chip {
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.ds-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

footer {
  padding: 12px 20px 20px;
  border-top: 1px solid var(--border);
}

#queryForm {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  transition: border-color 0.2s;
}

#queryForm:focus-within {
  border-color: var(--accent);
}

#queryInput {
  flex: 1;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  font-family: var(--font);
}

#queryInput::placeholder { color: var(--text-dim); }

#sendBtn {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

#sendBtn:hover { opacity: 0.85; }
#sendBtn:disabled { opacity: 0.4; cursor: default; }

@media (max-width: 480px) {
  header h1 { font-size: 1.1rem; }
  .message { max-width: 92%; }
  .bubble { font-size: 0.85rem; padding: 10px 14px; }
}
