:root {
  --bg: #08080b;
  --bg-elevated: #101014;
  --surface: #16161c;
  --surface-2: #1c1c24;
  --border: #26262f;
  --border-soft: #1e1e26;
  --text: #f5f5f7;
  --text-dim: #a3a3ad;
  --text-faint: #6b6b76;
  --accent: #7c6cf6;
  --accent-hover: #6e5ef0;
  --accent-soft: rgba(124, 108, 246, 0.14);
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --shadow-card: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.35);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Top nav */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(8,8,11,0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.topnav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b794f4);
  box-shadow: 0 0 12px var(--accent);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: var(--text); background: var(--surface-2); }
.nav-actions { display: flex; align-items: center; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-weight: 700;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); border-color: #34343f; }
.btn-danger { background: rgba(248,113,113,0.12); color: var(--danger); }
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-success { background: rgba(52,211,153,0.12); color: var(--success); }
.btn-success:hover { background: rgba(52,211,153,0.2); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }

/* Cards & surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card-tight { padding: 16px; border-radius: var(--radius-md); }

/* Hero */
.hero { padding: 90px 0 60px; text-align: center; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: #c9bffb;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  margin-bottom: 24px;
}
.hero h1 {
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.15;
  margin-bottom: 18px;
  background: linear-gradient(180deg, #fff 40%, #b8b8c4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  font-size: 18px;
  color: var(--text-dim);
  max-width: 620px;
  margin: 0 auto 32px;
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-actions .btn { padding: 13px 26px; font-size: 15px; }

.stats-row {
  display: flex; justify-content: center; gap: 48px; margin-top: 56px; flex-wrap: wrap;
}
.stat { text-align: center; }
.stat-num { font-size: 28px; font-weight: 800; }
.stat-label { font-size: 13px; color: var(--text-faint); margin-top: 4px; }

/* Forms */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px; font-weight: 700; color: var(--text-dim);
  margin-bottom: 7px;
}
.input, select.input, textarea.input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 14px;
  transition: border-color .15s ease;
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
}
textarea.input { resize: vertical; min-height: 90px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 440px;
  padding: 28px;
  max-height: 90vh; overflow-y: auto;
}
.modal-lg { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h2 { font-size: 20px; font-weight: 800; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.tab-switch { display: flex; gap: 4px; background: var(--bg-elevated); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.tab-switch button {
  flex: 1; padding: 8px; border: none; background: transparent; color: var(--text-dim);
  border-radius: 8px; font-family: var(--font); font-weight: 700; font-size: 13px; cursor: pointer;
}
.tab-switch button.active { background: var(--surface-2); color: var(--text); }

/* Grid & sections */
.section { padding: 56px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.section-head h2 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.section-head p { color: var(--text-dim); font-size: 14px; margin-top: 4px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
}

/* Project card */
.project-card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  padding: 18px; cursor: pointer; transition: all .15s ease; position: relative;
}
.project-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.pc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 999px;
  background: var(--accent-soft); color: #c9bffb; white-space: nowrap;
}
.badge-featured { background: rgba(251,191,36,0.14); color: var(--warning); }
.badge-status { background: var(--surface-2); color: var(--text-dim); }
.pc-title { font-size: 16px; font-weight: 800; margin-bottom: 6px; line-height: 1.4; }
.pc-summary { font-size: 13px; color: var(--text-dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 12px; }
.pc-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-faint); }
.pc-tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.tag-pill { font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); }

/* Chat */
.chat-window {
  height: 440px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 6px 2px; margin-bottom: 14px;
}
.msg { max-width: 82%; padding: 11px 15px; border-radius: 16px; font-size: 14px; line-height: 1.65; }
.msg-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-left-radius: 4px; }
.msg-assistant { align-self: flex-start; background: var(--surface-2); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input-row textarea { flex: 1; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: .6; }

/* Toast */
#toast-stack { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toast-in .2s ease;
}
.toast.error { border-color: rgba(248,113,113,0.4); color: #fca5a5; }
.toast.success { border-color: rgba(52,211,153,0.4); color: #6ee7b7; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Utility */
.hidden { display: none !important; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-center { text-align: center; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.divider { height: 1px; background: var(--border-soft); margin: 20px 0; border: none; }

.credit-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
}
.credit-chip .coin { color: var(--warning); }

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

.footer { border-top: 1px solid var(--border-soft); padding: 32px 0; text-align: center; color: var(--text-faint); font-size: 13px; margin-top: 60px; }

@media (max-width: 720px) {
  .nav-links { display: none; }
  .hero { padding: 60px 0 40px; }
  .stats-row { gap: 28px; }
  .modal { padding: 20px; }
}
