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

:root {
  --primary: #7C3AED;
  --primary-light: #EDE9FE;
  --primary-dark: #5B21B6;
  --success: #059669;
  --success-bg: #D1FAE5;
  --warning: #D97706;
  --warning-bg: #FEF3C7;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --info: #2563EB;
  --info-bg: #DBEAFE;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-500: #6B7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ── Nav ── */
.nav {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  max-width: 640px;
  margin: 0 auto;
}
.nav-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}
.nav-links a { color: var(--gray-700); text-decoration: none; }
.nav-links a:hover { color: var(--primary); }
.nav-credit {
  background: var(--primary-light);
  color: var(--primary) !important;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Layout ── */
.page {
  padding: 24px 16px;
  max-width: 640px;
  margin: 0 auto;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-outline { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-full { width: 100%; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--gray-700); }
input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
  background: white;
  font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 120px; }

/* ── Cards ── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-queued      { background: var(--gray-100); color: var(--gray-700); }
.badge-processing  { background: var(--info-bg);  color: var(--info); }
.badge-completed   { background: var(--success-bg); color: var(--success); }
.badge-failed      { background: var(--danger-bg);  color: var(--danger); }
.badge-rate_limited { background: var(--warning-bg); color: var(--warning); }

/* ── Auth pages ── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 32px 24px;
}
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .subtitle { font-size: 14px; color: var(--gray-500); margin-bottom: 24px; }

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #4F46E5 100%);
  color: white;
  padding: 52px 16px;
  text-align: center;
}
.hero h1 { font-size: 28px; font-weight: 800; line-height: 1.2; margin-bottom: 12px; }
.hero p { font-size: 16px; opacity: .85; margin-bottom: 28px; }
.hero-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── Steps ── */
.steps {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  text-align: center;
  padding: 8px 0;
}
.step-num {
  width: 36px; height: 36px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  margin: 0 auto 8px;
}
.step-label { font-size: 13px; color: var(--gray-700); font-weight: 500; }

/* ── Pricing ── */
.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pricing-card {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  text-align: center;
}
.pricing-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.pricing-card .credits { font-size: 26px; font-weight: 800; color: var(--primary); }
.pricing-card .credit-label { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; }
.pricing-card .price { font-size: 17px; font-weight: 700; }
.pricing-card .per { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ── Job items ── */
.job-item {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 10px;
}
.job-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.job-prompt {
  font-size: 14px;
  color: var(--gray-700);
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.job-meta { font-size: 12px; color: var(--gray-500); }

/* ── Balance widget ── */
.balance-widget {
  background: linear-gradient(135deg, var(--primary), #4F46E5);
  color: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.balance-widget .label { font-size: 13px; opacity: .8; }
.balance-widget .amount { font-size: 40px; font-weight: 800; line-height: 1.1; }
.balance-widget .unit { font-size: 15px; opacity: .8; }
.balance-widget .priority { font-size: 13px; margin-top: 6px; opacity: .9; }

/* ── Status block (create page) ── */
.status-block {
  text-align: center;
  padding: 32px 16px;
}
.status-block .status-icon { font-size: 32px; margin-bottom: 6px; line-height: 1; }
.status-block h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.status-block p { color: var(--gray-500); font-size: 14px; }

/* ── Video player ── */
.video-result { text-align: center; padding: 8px 0; }
.video-result .video-wrap { display: inline-block; aspect-ratio: 9/16; height: 45vh; max-width: 100%; border-radius: var(--radius); overflow: hidden; background: #000; }
.video-result video { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
}
.modal {
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 480px;
  padding: 24px;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  font-size: 20px; cursor: pointer; color: var(--gray-500);
  background: none; border: none; padding: 4px; line-height: 1;
}

/* ── QR / Bank info ── */
.qr-img {
  display: block; margin: 0 auto 16px;
  width: 200px; height: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}
.bank-info {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 14px;
}
.bank-row { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--gray-200); }
.bank-row:last-child { border-bottom: none; }
.bank-label { color: var(--gray-500); }
.bank-val { font-weight: 600; text-align: right; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gray-900); color: white;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 14px; z-index: 300;
  animation: slideUp .2s ease;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(16px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

/* ── Spinner ── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Notice ── */
.notice {
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--warning);
}

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--gray-500);
}
.empty-icon { font-size: 40px; margin-bottom: 10px; }

/* ── Error box ── */
.error-box {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ── Section title ── */
.section-title { font-size: 17px; font-weight: 700; margin: 20px 0 12px; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── Utils ── */
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--gray-500); }
.hidden { display: none !important; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

/* ── Responsive ── */
@media (max-width: 380px) {
  .pricing-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; gap: 8px; }
  .hero h1 { font-size: 24px; }
}
