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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0f1e;
  color: #e8eaf0;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 780px;
  padding: 16px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
}

header {
  text-align: center;
  padding: 12px 0 12px;
}

.logo {
  font-size: 36px;
  margin-bottom: 6px;
}

h1 {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.tagline {
  color: #8892a4;
  font-size: 0.85rem;
  margin-top: 5px;
  padding: 0 8px;
}

.stack {
  color: #3b82f6;
  font-size: 0.72rem;
  margin-top: 7px;
  letter-spacing: 0.3px;
  opacity: 0.8;
  padding: 0 8px;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #141929;
  border: 1px solid #1e2740;
  border-radius: 10px;
  padding: 10px 16px;
  margin: 12px 0;
  font-size: 0.85rem;
}

#status-text {
  color: #8892a4;
}

#status-text.ready {
  color: #4ade80;
}

#status-text.empty {
  color: #f59e0b;
}

.btn-secondary {
  background: #1e2740;
  color: #c8d0e0;
  border: 1px solid #2e3a54;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #263350;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  background: #0d1220;
  border: 1px solid #1e2740;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-message p {
  color: #8892a4;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-btn {
  background: #141929;
  border: 1px solid #1e2740;
  color: #a0aec0;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.2s;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.example-btn:hover {
  background: #1e2740;
  color: #e8eaf0;
  border-color: #3b82f6;
}

/* Messages */
.message {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message.user {
  align-items: flex-end;
}

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

.bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.message.user .bubble {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 3px;
}

.message.assistant .bubble {
  background: #141929;
  color: #d8e0f0;
  border: 1px solid #1e2740;
  border-bottom-left-radius: 3px;
}

.sources {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #5a6a84;
}

.sources strong {
  color: #8892a4;
  display: block;
  margin-bottom: 4px;
}

.source-item {
  background: #0a0f1e;
  border: 1px solid #1a2236;
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 4px;
  font-size: 0.75rem;
}

.source-url {
  color: #3b82f6;
  font-size: 0.72rem;
  word-break: break-all;
}

/* Input */
.input-area {
  display: flex;
  gap: 8px;
}

#question-input {
  flex: 1;
  background: #141929;
  border: 1px solid #1e2740;
  color: #e8eaf0;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 16px; /* prevents iOS auto-zoom on focus */
  outline: none;
  transition: border-color 0.2s;
  min-height: 48px;
}

#question-input:focus {
  border-color: #3b82f6;
}

#question-input::placeholder {
  color: #3d4a60;
}

#ask-btn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

#ask-btn:active {
  transform: scale(0.97);
}

#ask-btn:hover {
  background: #1d4ed8;
}

#ask-btn:disabled {
  background: #1e2740;
  color: #4a5568;
  cursor: not-allowed;
}

/* Loading dots */
.loading-bubble {
  background: #141929;
  border: 1px solid #1e2740;
  padding: 12px 16px;
  border-radius: 12px;
  border-bottom-left-radius: 3px;
}

.dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #4a5a74;
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce 1.2s infinite;
}

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

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

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #141929;
  border: 1px solid #1e2740;
  border-radius: 14px;
  padding: 32px;
  max-width: 400px;
  text-align: center;
}

.modal-content h2 {
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.modal-content p {
  color: #8892a4;
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #1e2740;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 16px auto;
}

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

#crawl-progress {
  color: #4ade80;
  font-size: 0.82rem;
}

/* Web search badge */
.web-badge {
  display: inline-block;
  font-size: 0.72rem;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 4px;
  padding: 2px 8px;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

/* Scrollbar */
.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: #1e2740; border-radius: 2px; }
