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

:root {
  --bg: #0a0e17;
  --bg2: #111827;
  --bg3: #1a2234;
  --surface: #1e293b;
  --border: #2d3a4f;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --accent: #6366f1;
  --accent2: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --orange: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Landing Page ---- */
.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10, 14, 23, 0.9);
  backdrop-filter: blur(12px);
  z-index: 100;
}
.landing-nav .logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.landing-nav .logo span { color: var(--accent2); }
.landing-nav .nav-links { display: flex; gap: 24px; align-items: center; }
.landing-nav .nav-links a { color: var(--text2); font-size: 14px; font-weight: 500; }
.landing-nav .nav-links a:hover { color: var(--text); text-decoration: none; }

.hero {
  text-align: center;
  padding: 80px 24px 60px;
  max-width: 800px;
  margin: 0 auto;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #e2e8f0 0%, #818cf8 50%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero .subtitle {
  font-size: clamp(16px, 2.5vw, 20px);
  color: var(--text2);
  max-width: 600px;
  margin: 0 auto 32px;
}
.hero .cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: #5558e6; transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg3); border-color: var(--text3); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-ghost { background: none; border: none; color: var(--text2); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

/* Demo preview */
.demo-preview {
  max-width: 900px;
  margin: 0 auto 80px;
  padding: 0 24px;
}
.demo-window {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.demo-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.demo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
}
.demo-dot:nth-child(1) { background: #ef4444; }
.demo-dot:nth-child(2) { background: #f59e0b; }
.demo-dot:nth-child(3) { background: #22c55e; }
.demo-body {
  padding: 24px;
  font-size: 14px;
}
.demo-prompt {
  color: var(--text2);
  margin-bottom: 12px;
}
.demo-prompt b { color: var(--accent2); }
.demo-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  color: var(--text);
}
.demo-code .kw { color: #c792ea; }
.demo-code .fn { color: #82aaff; }
.demo-code .str { color: #c3e88d; }
.demo-code .cm { color: #546e7a; }
.demo-code .num { color: #f78c6c; }

/* Features */
.features {
  max-width: 1100px;
  margin: 0 auto;
  padding: 60px 24px;
}
.features h2 {
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 48px;
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}
.feature-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color 0.2s;
}
.feature-card:hover { border-color: var(--accent); }
.feature-card .icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
  background: var(--accent-glow);
}
.feature-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.feature-card p { color: var(--text2); font-size: 14px; }

/* Pricing */
.pricing {
  max-width: 1000px;
  margin: 0 auto;
  padding: 80px 24px;
}
.pricing h2 { text-align: center; font-size: 32px; font-weight: 700; margin-bottom: 12px; }
.pricing .subtitle { text-align: center; color: var(--text2); margin-bottom: 48px; }
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.price-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  flex-direction: column;
}
.price-card.featured {
  border-color: var(--accent);
  box-shadow: 0 0 30px var(--accent-glow);
  position: relative;
}
.price-card.featured::before {
  content: 'Most Popular';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 20px;
}
.price-card h3 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.price-card .price { font-size: 40px; font-weight: 800; margin: 16px 0 4px; }
.price-card .price span { font-size: 16px; font-weight: 400; color: var(--text2); }
.price-card .period { color: var(--text3); font-size: 14px; margin-bottom: 24px; }
.price-card ul { list-style: none; margin-bottom: 24px; flex: 1; }
.price-card li {
  padding: 6px 0;
  font-size: 14px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.price-card li::before { content: '✓'; color: var(--green); font-weight: 700; }
.price-card .btn { width: 100%; justify-content: center; }

/* Footer */
.landing-footer {
  border-top: 1px solid var(--border);
  padding: 32px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* ---- Auth Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal h2 { font-size: 22px; margin-bottom: 24px; text-align: center; }
.modal .form-group { margin-bottom: 16px; }
.modal label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.modal input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
}
.modal input:focus { outline: none; border-color: var(--accent); }
.modal .error { color: var(--red); font-size: 13px; margin-top: 8px; }
.modal .switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text3); }
.modal .switch a { color: var(--accent2); cursor: pointer; }

/* ---- App Layout ---- */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  overflow: hidden;
}
.app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.app-header .logo {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header .logo span { color: var(--accent2); }
.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text2);
}
.app-header .plan-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--accent-glow);
  color: var(--accent2);
}
.plan-badge.pro { background: var(--green-bg); color: var(--green); }

.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-section {
  padding: 16px;
}
.sidebar-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  margin-bottom: 8px;
}
.mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--text2);
  font-size: 14px;
  font-family: var(--font);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.mode-btn:hover { background: var(--bg3); color: var(--text); }
.mode-btn.active { background: var(--accent-glow); color: var(--accent2); font-weight: 500; }
.mode-btn .icon { font-size: 18px; width: 24px; text-align: center; }

.convo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  transition: background 0.15s;
}
.convo-item:hover { background: var(--bg3); }
.convo-item.active { background: var(--accent-glow); color: var(--accent2); }
.convo-item .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.convo-item .del { opacity: 0; border: none; background: none; color: var(--text3); cursor: pointer; font-size: 16px; padding: 0 4px; }
.convo-item:hover .del { opacity: 1; }

/* Main chat area */
.main-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.context-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  font-size: 13px;
}
.context-bar label { color: var(--text3); font-weight: 500; }
.context-bar input, .context-bar select {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
}
.context-bar input:focus, .context-bar select:focus { outline: none; border-color: var(--accent); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.message {
  margin-bottom: 20px;
  max-width: 860px;
}
.message.user {
  margin-left: auto;
}
.message .bubble {
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
}
.message.user .bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}
.message.assistant .bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.message .meta {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  padding: 0 4px;
}
.message.user .meta { text-align: right; }

/* Code blocks in messages */
.message pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  position: relative;
}
.message code {
  font-family: var(--mono);
  font-size: 13px;
}
.message :not(pre) > code {
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
}
.copy-btn:hover { background: var(--bg3); color: var(--text); }

/* Input area */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 860px;
  margin: 0 auto;
}
.chat-textarea {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  resize: none;
  min-height: 48px;
  max-height: 200px;
  line-height: 1.5;
}
.chat-textarea:focus { outline: none; border-color: var(--accent); }
.chat-textarea::placeholder { color: var(--text3); }
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.send-btn:hover { background: #5558e6; }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.quota-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
  margin-top: 8px;
}
.quota-fill {
  flex: 1;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  max-width: 120px;
}
.quota-fill-inner {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

/* Loading animation */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 16px;
}
.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text3);
  text-align: center;
  padding: 40px;
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.empty-state p { max-width: 400px; font-size: 14px; line-height: 1.6; }
.example-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  justify-content: center;
  max-width: 600px;
}
.example-prompt {
  padding: 8px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.example-prompt:hover { border-color: var(--accent); color: var(--accent2); }

/* Responsive */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .hero { padding: 40px 16px 30px; }
  .feature-grid { grid-template-columns: 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .landing-nav .nav-links a:not(.btn) { display: none; }
}
