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

:root {
  --bg: #f4f4f8;
  --surface: #ffffff;
  --surface-hover: #f0f0f5;
  --text: #18181b;
  --text-secondary: #71717a;
  --border: rgba(0,0,0,0.07);
  --accent: #6c5ce7;
  --accent-hover: #5a4bd1;
  --radius: 12px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── NAV ─── */
nav {
  position: fixed;
  top: 0;
  width: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 60px;
}

.logo {
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-right a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-right a:hover {
  color: var(--text);
}

.nav-signin {
  background: var(--accent);
  color: #fff !important;
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 13px !important;
  font-weight: 600 !important;
  transition: background 0.2s !important;
}

.nav-signin:hover {
  background: var(--accent-hover) !important;
}

/* ─── HERO ─── */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 24px 80px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108,92,231,0.07), transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.hero h1 {
  font-size: clamp(44px, 7vw, 68px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin-bottom: 18px;
  position: relative;
}

.gradient-text {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: clamp(17px, 2.2vw, 20px);
  color: var(--text-secondary);
  max-width: 560px;
  line-height: 1.6;
  margin-bottom: 36px;
  position: relative;
}

.hero-buttons {
  display: flex;
  gap: 12px;
  position: relative;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 30px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

/* ─── FEATURES ─── */
#features {
  max-width: 1100px;
  margin: 0 auto;
  padding: 100px 24px;
}

.section-header {
  text-align: center;
  margin-bottom: 56px;
}

.section-header h2 {
  font-size: clamp(32px, 4.5vw, 46px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 17px;
  margin-top: 12px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  transition: all 0.3s;
}

.feature-card:hover {
  border-color: rgba(108,92,231,0.25);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.06);
}

.card-icon {
  width: 44px;
  height: 44px;
  background: rgba(108,92,231,0.08);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: var(--accent);
}

.feature-card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}

.feature-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ─── ABOUT ─── */
#about {
  background: var(--surface);
  padding: 100px 24px;
}

.about-content {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 60px;
}

.about-text {
  flex: 1;
}

.about-text h2 {
  font-size: clamp(30px, 3.5vw, 42px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 20px;
}

.about-text p {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
}

.about-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.stat-number {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #6c5ce7, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-suffix {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-left: auto;
}

/* ─── CONTACT ─── */
#contact {
  max-width: 560px;
  margin: 0 auto;
  padding: 100px 24px;
  text-align: center;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 32px;
}

.input-group input,
.input-group textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus,
.input-group textarea:focus {
  border-color: var(--accent);
}

.input-group textarea {
  resize: vertical;
}

.contact-form .btn {
  align-self: center;
}

/* ─── FOOTER ─── */
footer {
  text-align: center;
  padding: 28px 24px;
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px 32px;
  width: 100%;
  max-width: 400px;
  position: relative;
  transform: scale(0.93) translateY(12px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(0,0,0,0.05);
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.modal-close:hover {
  background: rgba(0,0,0,0.1);
}

.modal-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}

.modal-tab {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.modal-tab.active {
  background: var(--accent);
  color: #fff;
}

.modal-panel {
  display: none;
}

.modal-panel.active {
  display: block;
}

.modal-panel h3 {
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form .input-group input {
  background: var(--bg);
}

.btn-full {
  width: 100%;
  margin-top: 6px;
}

.auth-divider {
  text-align: center;
  margin: 20px 0;
  position: relative;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  background: var(--surface);
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 12px;
  position: relative;
}

.social-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-social {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  gap: 10px;
}

.btn-social:hover {
  background: var(--surface-hover);
}

.auth-terms {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 20px;
  line-height: 1.5;
}

/* ─── DASHBOARD ─── */
.dashboard-body {
  background: var(--bg);
}

.dashboard {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.dash-header {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.dash-header-left .logo {
  font-size: 18px;
  font-weight: 800;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.dash-btn:hover {
  background: var(--surface-hover);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.dash-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Center ─── */
.dash-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px;
  min-width: 0;
}

.welcome {
  margin-bottom: 24px;
}

.welcome h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.welcome p {
  color: var(--text-secondary);
  font-size: 15px;
}

.chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 16px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 680px;
  animation: msgIn 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.message.bot .msg-avatar {
  background: rgba(108,92,231,0.12);
  color: var(--accent);
}

.msg-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.6;
}

.message.user .msg-content {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  margin-top: 16px;
}

.chat-input-bar input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}

.chat-input-bar button {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-input-bar button:hover {
  background: var(--accent-hover);
}

/* ─── Sidebar ─── */
.dash-sidebar {
  width: 280px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-user {
  text-align: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.avatar-large {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 auto 12px;
}

.sidebar-user h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.sidebar-email {
  font-size: 13px;
  color: var(--text-secondary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-link.active {
  background: rgba(108,92,231,0.08);
  color: var(--accent);
}

#signOutBtn {
  margin-top: auto;
  color: #ef4444;
}

#signOutBtn:hover {
  background: rgba(239,68,68,0.08);
}

.sidebar-plan {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.plan-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 6px;
  background: rgba(108,92,231,0.08);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 10px;
}

.plan-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.plan-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.sidebar-plan p {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ─── MODEL SELECTOR ─── */
.model-selector {
  margin-left: 24px;
}

.model-selector select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 28px 6px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.2s;
}

.model-selector select:hover {
  border-color: var(--accent);
}

/* ─── API KEY SECTION (sidebar) ─── */
.api-key-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.api-key-section h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.api-status {
  font-size: 12px;
  margin-bottom: 8px;
}

.api-status.connected {
  color: #22c55e;
}

.api-status.disconnected {
  color: #f59e0b;
}

.btn-small {
  padding: 5px 12px !important;
  font-size: 12px !important;
}

/* ─── API KEY MODAL ─── */
.modal-sm {
  max-width: 380px !important;
}

.api-modal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.api-get-key {
  display: block;
  text-align: center;
  margin-top: 16px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.api-get-key:hover {
  text-decoration: underline;
}

/* ─── TYPING INDICATOR ─── */
.message.typing .msg-content {
  background: var(--surface);
}

.typing-dots span {
  display: inline-block;
  animation: dotPulse 1.4s infinite;
  font-size: 24px;
  line-height: 1;
  color: var(--text-secondary);
}

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

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

@keyframes dotPulse {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ─── DASHBOARD DASH-HEADER LAYOUT ─── */
.dash-header-left {
  display: flex;
  align-items: center;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .about-content {
    flex-direction: column;
    text-align: center;
  }
  .stat-label {
    margin-left: 0;
    width: 100%;
  }
  .nav-right {
    gap: 16px;
  }
  .nav-right a {
    font-size: 13px;
  }
  .modal {
    margin: 0 12px;
    padding: 32px 20px;
  }
}
