* {
  box-sizing: border-box;
  font-family: Inter, system-ui, sans-serif;
}

body {
  margin: 0;
  background: #0f1117;
  color: #e5e7eb;
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: 100vh;
}

.app {
  width: 100%;
  max-width: 420px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #1f2937;
}

.header h1 {
  margin: 0;
  font-size: 20px;
}

.header p {
  margin: 4px 0 0;
  font-size: 13px;
  color: #9ca3af;
}

.header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.header button {
  background: #2563eb;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}

.header button:hover {
  background: #1d4ed8;
}

.knowledge-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  background: #059669 !important;
}

.knowledge-btn:hover {
  background: #047857 !important;
}

.knowledge-btn svg {
  width: 14px;
  height: 14px;
}

/* Chat */
.chat-container {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
}

.message {
  max-width: 75%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: 10px;
  line-height: 1.4;
  font-size: 14px;
  overflow-wrap: break-word;
}

.message.user {
  background: #2563eb;
  margin-left: auto;
  color: white;
}

.message.bot {
  background: #1f2937;
}

.message.system {
  background: #111827;
  color: #9ca3af;
  text-align: center;
  max-width: 100%;
}

/* Input bar */
.input-bar {
  display: flex;
  align-items: center;
  padding: 10px;
  border-top: 1px solid #1f2937;
  gap: 8px;
}

.input-bar input {
  flex: 1;
  background: #111827;
  border: 1px solid #1f2937;
  color: white;
  padding: 10px 12px;
  border-radius: 8px;
  outline: none;
  min-width: 0;
}

.input-bar button {
  background: #2563eb;
  border: none;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.upload-btn-modern {
  background: #10b981;
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.upload-btn-modern:hover {
  background: #059669;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.upload-btn-modern:active {
  transform: scale(0.95);
}

.upload-input {
  display: none;
}

/* Info */
.info {
  font-size: 12px;
  text-align: center;
  padding: 6px;
  color: #9ca3af;
}

/* Loader */
.loader {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #1f2937;
  border-top: 4px solid #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.citations {
  margin: 6px 0 16px 0;
  padding-left: 10px;
  border-left: 2px solid #1f2937;
}

.citations-title {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 4px;
}

.citation-item {
  font-size: 12px;
  color: #d1d5db;
  margin-bottom: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Chat row */
.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.chat-row.user {
  justify-content: flex-end;
}

/* Avatar */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #9333ea);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

/* Bot avatar */
.avatar.bot {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

/* Glassmorphism message bubble */
.message {
  max-width: 68%;
  padding: 10px 12px;
  font-size: 13.5px;
  border-radius: 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(31, 41, 55, 0.65);
  border: 1px solid rgba(255,255,255,0.08);
  line-height: 1.4;
}

/* User bubble */
.chat-row.user .message {
  background: rgba(37, 99, 235, 0.75);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Bot bubble */
.chat-row.bot .message {
  border-bottom-left-radius: 4px;
}

/* Bot thinking animation */
.avatar.thinking {
  animation: pulse 1.2s infinite ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}
