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

:root {
  --blue: #0055FF;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --dark: #00143D;
  --coral: #FC6058;
  --coral-light: #fff1f0;
  --bg: #f8fafc;
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.04);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--gray-700);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  background: var(--white);
  box-shadow: -1px 0 0 var(--gray-200), 1px 0 0 var(--gray-200);
}

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--dark) 0%, #0a2463 100%);
  color: var(--white);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 8px rgba(252, 96, 88, 0.4);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(252, 96, 88, 0.4); }
  50% { box-shadow: 0 0 16px rgba(252, 96, 88, 0.7); }
}

.logo-text {
  font-weight: 700;
  font-size: 18px;
  color: var(--white);
  letter-spacing: -0.3px;
}

.logo-label {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
  padding: 2px 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.btn-icon {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 7px;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.2);
  color: var(--white);
}

/* ─── Quick Actions ─── */
.quick-actions {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar { display: none; }

.chip {
  white-space: nowrap;
  padding: 7px 16px;
  border-radius: 100px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip:hover {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue);
  box-shadow: var(--shadow-sm);
}

.chip:active {
  transform: scale(0.97);
}

/* ─── Chat ─── */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--gray-50);
}

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

.welcome-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--blue-50) 0%, var(--blue-100) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.welcome h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.5px;
}

.welcome p {
  font-size: 15px;
  color: var(--gray-500);
  max-width: 460px;
  line-height: 1.6;
}

.welcome-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  max-width: 520px;
  width: 100%;
}

.suggestion {
  padding: 14px 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  text-align: left;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
}

.suggestion:hover {
  border-color: var(--blue-200);
  background: var(--blue-50);
  color: var(--blue);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.suggestion:active {
  transform: translateY(0);
}

.suggestion-icon {
  font-size: 16px;
  display: block;
  margin-bottom: 4px;
}

/* ─── Messages ─── */
.message {
  display: flex;
  gap: 12px;
  max-width: 100%;
  animation: msgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message.user {
  justify-content: flex-end;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-700) 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(0, 85, 255, 0.25);
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--gray-700) 0%, var(--gray-900) 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.message-bubble {
  max-width: 82%;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.7;
  word-wrap: break-word;
}

.message.assistant .message-bubble {
  background: var(--white);
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
  box-shadow: var(--shadow-sm);
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-700) 100%);
  color: var(--white);
  box-shadow: 0 2px 12px rgba(0, 85, 255, 0.2);
}

/* ─── Markdown ─── */
.message.assistant .message-bubble h1,
.message.assistant .message-bubble h2,
.message.assistant .message-bubble h3 {
  margin: 16px 0 8px;
  color: var(--gray-900);
  letter-spacing: -0.3px;
}

.message.assistant .message-bubble h1 { font-size: 18px; font-weight: 700; }
.message.assistant .message-bubble h2 { font-size: 16px; font-weight: 700; }
.message.assistant .message-bubble h3 { font-size: 14px; font-weight: 600; }

.message.assistant .message-bubble h1:first-child,
.message.assistant .message-bubble h2:first-child,
.message.assistant .message-bubble h3:first-child {
  margin-top: 0;
}

.message.assistant .message-bubble p {
  margin: 8px 0;
}

.message.assistant .message-bubble p:first-child { margin-top: 0; }
.message.assistant .message-bubble p:last-child { margin-bottom: 0; }

.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol {
  margin: 8px 0;
  padding-left: 22px;
}

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

.message.assistant .message-bubble code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', Monaco, 'Cascadia Code', monospace;
  color: var(--coral);
}

.message.assistant .message-bubble pre {
  background: var(--gray-900);
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow);
}

.message.assistant .message-bubble pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.message.assistant .message-bubble strong {
  color: var(--gray-900);
  font-weight: 600;
}

.message.assistant .message-bubble em {
  color: var(--gray-600);
}

.message.assistant .message-bubble blockquote {
  border-left: 3px solid var(--blue);
  padding: 8px 14px;
  margin: 10px 0;
  color: var(--gray-500);
  background: var(--blue-50);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}

.message.assistant .message-bubble hr {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 14px 0;
}

.message.assistant .message-bubble a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.message.assistant .message-bubble a:hover {
  border-bottom-color: var(--blue);
}

.message.assistant .message-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 13px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.message.assistant .message-bubble th,
.message.assistant .message-bubble td {
  border: 1px solid var(--gray-200);
  padding: 8px 12px;
  text-align: left;
}

.message.assistant .message-bubble th {
  background: var(--gray-100);
  font-weight: 600;
  color: var(--gray-800);
}

.message.assistant .message-bubble tr:nth-child(even) td {
  background: var(--gray-50);
}

/* ─── Search indicator ─── */
.search-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--blue);
  font-weight: 500;
  animation: msgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--blue-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* ─── Typing ─── */
.typing {
  display: inline-flex;
  gap: 5px;
  padding: 4px 0;
  align-items: center;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-200);
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

/* ─── Footer ─── */
.footer {
  padding: 16px 24px 20px;
  background: var(--white);
  border-top: 1px solid var(--gray-100);
}

.input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.input-area:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 85, 255, 0.1), var(--shadow-sm);
}

#input {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  font-size: 14px;
  font-family: var(--font);
  color: var(--gray-800);
  line-height: 1.5;
  max-height: 140px;
  outline: none;
}

#input::placeholder {
  color: var(--gray-400);
}

.send-btn {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-700) 100%);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 85, 255, 0.25);
}

.send-btn:disabled {
  background: var(--gray-200);
  color: var(--gray-400);
  cursor: not-allowed;
  box-shadow: none;
}

.send-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 85, 255, 0.35);
}

.send-btn:not(:disabled):active {
  transform: translateY(0);
}

.footer-note {
  text-align: center;
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 10px;
}

/* ─── Scrollbar ─── */
.chat::-webkit-scrollbar {
  width: 6px;
}

.chat::-webkit-scrollbar-track {
  background: transparent;
}

.chat::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: 3px;
}

.chat::-webkit-scrollbar-thumb:hover {
  background: var(--gray-300);
}

/* ─── Mobile ─── */
@media (max-width: 640px) {
  .app {
    max-width: 100%;
    box-shadow: none;
  }

  .header {
    padding: 12px 16px;
  }

  .quick-actions {
    padding: 10px 16px;
    gap: 6px;
  }

  .chip {
    padding: 6px 12px;
    font-size: 12px;
  }

  .chat {
    padding: 16px;
    gap: 16px;
  }

  .footer {
    padding: 12px 16px 16px;
  }

  .message-bubble {
    max-width: 90%;
    padding: 12px 14px;
  }

  .welcome {
    padding: 24px 16px;
  }

  .welcome h2 {
    font-size: 20px;
  }

  .welcome-suggestions {
    grid-template-columns: 1fr;
  }
}
