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

:root {
  --bg-0: #0B1117;
  --bg-1: #111318;
  --bg-2: #1A1F2B;
  --primary: #4CD9B2;
  --primary-dark: #3ab897;
  --primary-glow: rgba(76,217,178,0.15);
  --text-1: #dce1fb;
  --text-2: #c8c5d0;
  --text-3: #8a949e;
  --border: #2a313d;
  --border-glow: rgba(76,217,178,0.12);
  --red: #f87171;
  --radius: 4px;
  --radius-lg: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg-0);
  color: var(--text-1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
h1, h2, h3 { font-family: 'Manrope', sans-serif; font-weight: 700; letter-spacing: -0.03em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Inputs */
.input {
  width: 100%;
  padding: .75rem 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: .875rem;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: rgba(138,148,158,0.4); }
.input:focus { border-color: rgba(76,217,178,0.5); box-shadow: 0 0 0 2px rgba(76,217,178,0.12); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg-0);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 24px var(--primary-glow), 0 4px 12px rgba(76,217,178,0.2);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

/* Cards */
.card {
  background: rgba(17,19,24,0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color .3s, box-shadow .3s;
}
.card:hover {
  border-color: rgba(76,217,178,0.25);
  box-shadow: 0 0 20px rgba(76,217,178,0.06);
}

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* Background */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(76,217,178,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(76,217,178,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
.bg-blob {
  position: absolute; border-radius: 50%; pointer-events: none;
  filter: blur(120px); animation: float 8s ease-in-out infinite;
}

/* Header bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(17,19,24,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(76,217,178,0.06);
  padding: .75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}

/* App grid */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* Badge */
.badge {
  display: inline-block;
  font-size: .625rem;
  font-weight: 600;
  padding: .125rem .5rem;
  border-radius: 9999px;
}

/* Chat layout */
.chat-wrap { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 1.5rem;
  scroll-behavior: smooth;
}
.chat-msg { display: flex; gap: .75rem; margin-bottom: 1.25rem; max-width: 85%; }
.chat-msg.user { margin-left: auto; flex-direction: row-reverse; }
.chat-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
}
.chat-msg.ai .chat-avatar { background: var(--bg-2); border: 1px solid var(--border-glow); color: var(--primary); }
.chat-msg.user .chat-avatar { background: var(--primary); color: var(--bg-0); font-weight: 600; }
.chat-bubble {
  padding: .75rem 1rem; border-radius: var(--radius-lg);
  font-size: .875rem; line-height: 1.7; word-break: break-word;
}
.chat-msg.ai .chat-bubble { background: var(--bg-2); border: 1px solid rgba(42,49,61,0.5); }
.chat-msg.user .chat-bubble { background: rgba(76,217,178,0.12); border: 1px solid rgba(76,217,178,0.2); }
.chat-bubble p { margin-bottom: .5rem; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul, .chat-bubble ol { padding-left: 1.25rem; margin-bottom: .5rem; }
.chat-bubble code {
  background: var(--bg-1); padding: .1rem .35rem; border-radius: 3px;
  font-family: 'JetBrains Mono', monospace; font-size: .8125rem;
}
.chat-bubble pre {
  background: var(--bg-1); padding: .75rem; border-radius: var(--radius);
  margin: .5rem 0; overflow-x: auto; border: 1px solid rgba(76,217,178,0.06);
}
.chat-bubble pre code { background: none; padding: 0; }
.chat-bubble strong { color: var(--primary); font-weight: 600; }
.chat-bubble a { color: var(--primary); }

/* Chat input */
.chat-input-area {
  padding: .75rem 1.5rem 1rem;
  background: var(--bg-1);
  border-top: 1px solid rgba(76,217,178,0.06);
}
.chat-input-row { display: flex; gap: .5rem; align-items: flex-end; }
.chat-input-row textarea {
  flex: 1; resize: none;
  min-height: 44px; max-height: 120px;
  padding: .625rem 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  font-size: .875rem;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
}
.chat-input-row textarea:focus { border-color: rgba(76,217,178,0.5); }
.chat-send {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  background: var(--primary); color: var(--bg-0);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .2s;
}
.chat-send:hover:not(:disabled) { background: var(--primary-dark); }
.chat-send:disabled { opacity: .3; cursor: not-allowed; }

/* Typing dots */
.typing-dots { display: flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3); animation: pulse 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

/* Animations */
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }
@keyframes fadeIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes spin { from { transform:rotate(0deg); } to { transform:rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:.3; } 50% { opacity:1; } }
.fade-in { animation: fadeIn .4s cubic-bezier(.19,1,.22,1); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: rgba(76,217,178,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(76,217,178,0.25); }

/* Mobile */
@media (max-width: 640px) {
  .app-grid { grid-template-columns: 1fr; }
  .container { padding: 0 1rem; }
  h1 { font-size: 1.5rem; }
  .chat-msg { max-width: 92%; }
  .chat-input-area { padding: .75rem 1rem; }
}
