/* ============================================
   rojak.app Studio, Motion Sync platform
   Mobile-first. Inherits design tokens from the main store style.css
   so the studio feels like part of the same brand.
   ============================================ */

:root {
  --bg: #fafafa;
  --bg-alt: #f0f0f0;
  --surface: #ffffff;
  --surface-dark: #062413;
  --surface-accent: #fff8e1;
  --text: #062413;
  --text-soft: #525252;
  --text-mute: #888;
  --text-on-dark: #ffffff;
  --border: #e8e8e8;
  --border-dark: #1f1f1f;
  --accent: #ff6b00;
  --accent-2: #ffae00;
  --success: #16a34a;
  --danger: #dc2626;
  --info: #2563eb;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-cta: 0 6px 16px rgba(10,10,10,0.18);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100dvh;
}

img, video { max-width: 100%; display: block; }
a { color: var(--text); text-decoration: none; }

/* ============ TOP BAR ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-brand {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.2px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.topbar-brand .dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: url(/studio/icons/icon-96.png) center / cover no-repeat;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-soft);
  padding: 6px 10px;
  margin-left: -10px;
}
.credits-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-dark);
  color: #fff;
  padding: 7px 13px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}
.credits-chip-icon { color: var(--accent-2); }

/* ============ PAGE WRAP ============ */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px calc(40px + var(--safe-bottom));
}
.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.15;
  margin: 4px 0 6px;
}
.page-sub {
  font-size: 15px;
  color: var(--text-soft);
  margin: 0 0 24px;
}

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.card-dark {
  background: var(--surface-dark);
  color: var(--text-on-dark);
  border-color: var(--border-dark);
}
.card h2 {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -0.2px;
}
.card p { font-size: 14px; color: var(--text-soft); margin: 0; }
.card-dark p { color: rgba(255,255,255,0.78); }

/* ============ FORMS ============ */
.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field-hint {
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 6px;
}
.input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 14px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  transition: border-color 150ms, box-shadow 150ms;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(10,10,10,0.06);
}
.input-error { border-color: var(--danger); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 100ms, box-shadow 150ms, opacity 150ms;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--surface-dark);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-cta);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-cta);
}
.btn-ghost {
  background: var(--bg-alt);
  color: var(--text);
}
.btn-text {
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 14px;
  width: auto;
}

/* ============ ALERTS / TOASTS ============ */
.alert {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.45;
}
.alert-success { background: #ecfdf5; border: 1px solid #10b981; color: #064e3b; }
.alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #7f1d1d; }
.alert-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1e3a8a; }
.alert-warn    { background: #fffbe6; border: 1px solid #ffe58f; color: #78350f; }

/* ============ DASHBOARD ============ */
.balance-card {
  background: var(--surface-dark);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 22px 22px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-md);
}
.balance-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  opacity: 0.7;
}
.balance-amount {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1.05;
  margin: 6px 0 4px;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}
.balance-amount .unit { font-size: 16px; font-weight: 600; opacity: 0.7; }
.balance-help { font-size: 13px; opacity: 0.7; margin-bottom: 14px; }
.balance-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.balance-actions .btn { padding: 12px 14px; font-size: 14px; }
.balance-actions .btn-primary { background: #fff; color: #062413; }
.balance-actions .btn-ghost { background: rgba(255,255,255,0.12); color: #fff; }

/* ============ FEATURE TILES ============ */
.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 8px;
}
.feature-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  transition: transform 120ms, box-shadow 150ms;
}
.feature-tile:active { transform: scale(0.99); }
.feature-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--surface-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.feature-tile-body { flex: 1; min-width: 0; }
.feature-tile-title { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.feature-tile-desc { font-size: 13px; color: var(--text-soft); line-height: 1.4; }
.feature-tile-arrow { color: var(--text-mute); font-size: 18px; }

/* ============ RECENT GENS ============ */
.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-weight: 700;
  margin: 24px 0 10px;
}
.gen-list { display: flex; flex-direction: column; gap: 10px; }
.gen-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
}
.gen-status { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.gen-status.processing { background: #fef3c7; color: #92400e; }
.gen-status.completed { background: #d1fae5; color: #065f46; }
.gen-status.failed { background: #fee2e2; color: #991b1b; }
.gen-time { color: var(--text-mute); font-size: 12px; }

.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-mute);
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* ============ LOGIN PAGE ============ */
.auth-container {
  max-width: 420px;
  margin: 0 auto;
  padding: 40px 20px;
  min-height: calc(100dvh - 60px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-logo {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.auth-logo .dot {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: url(/studio/icons/icon-96.png) center / cover no-repeat;
  box-shadow: 0 4px 14px rgba(74, 222, 128, 0.2);
}
.auth-tagline {
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
  margin-bottom: 32px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
}
.auth-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.4px; }
.auth-sub { font-size: 14px; color: var(--text-soft); margin-bottom: 22px; }
.auth-footnote { font-size: 12px; color: var(--text-mute); text-align: center; margin-top: 22px; line-height: 1.6; }
.auth-footnote a { color: var(--text-soft); text-decoration: underline; }

/* ============ DESKTOP TWEAKS ============ */
@media (min-width: 720px) {
  .page-title { font-size: 32px; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
}

/* ============ UTILITIES ============ */
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 14px; }
.mb-3 { margin-bottom: 22px; }
.hidden { display: none !important; }
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ LOGIN TABS ============ */
.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.login-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-mute);
  cursor: pointer;
  position: relative;
  bottom: -1px;
}
.login-tab.active {
  color: var(--text);
  border-bottom: 2px solid var(--text);
}


/* ============ BETA INDICATOR ============ */
.beta-pill {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  cursor: help;
}

/* ============================================
   REFERRAL CARD
   ============================================ */
.referral-card {
  display: flex;
  gap: 16px;
  background: linear-gradient(135deg, #0a3825 0%, #062413 100%);
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.referral-card-urgent {
  border-color: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}
.referral-card-icon {
  font-size: 32px;
  flex-shrink: 0;
  line-height: 1;
}
.referral-card-body { flex: 1; min-width: 0; }
.referral-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 4px;
  line-height: 1.35;
}
.referral-card-sub {
  font-size: 13px;
  color: var(--text-mute);
  margin-bottom: 14px;
  line-height: 1.5;
}
.referral-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.referral-link-input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(74, 222, 128, 0.2);
  color: var(--text-soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.referral-link-input:focus { outline: 1px solid #4ade80; }
.referral-copy-btn {
  flex-shrink: 0;
  padding: 10px 16px;
  font-size: 13px;
}
.referral-stats {
  font-size: 12px;
  color: var(--text-mute);
  margin-bottom: 12px;
}
.referral-stats strong { color: #4ade80; font-weight: 700; }
.referral-cap-note {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: rgba(74, 222, 128, 0.12);
  border-radius: 999px;
  font-size: 11px;
}
.referral-captions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.referral-captions-label {
  font-size: 11px;
  color: var(--text-mute);
  margin-right: 4px;
  width: 100%;
  margin-bottom: 2px;
}
.caption-pill {
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.25);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.caption-pill:active { transform: scale(0.97); }
.caption-pill:hover { background: rgba(74, 222, 128, 0.2); }

/* Mobile stacking */
@media (max-width: 480px) {
  .referral-card { flex-direction: column; gap: 12px; }
  .referral-link-row { flex-direction: column; }
  .referral-link-input { font-size: 12px; }
  .referral-copy-btn { width: 100%; }
}
