/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }

:root {
  /* palette */
  --bg:          #ffffff;
  --bg-subtle:   #fafafa;
  --bg-hover:    #f5f5f5;
  --border:      #e5e5e5;
  --border-strong:#d4d4d4;
  --text:        #0a0a0a;
  --text-muted:  #737373;
  --text-faint:  #a3a3a3;
  --accent:      #0a0a0a;
  --accent-hover:#262626;
  --destructive: #dc2626;
  --success:     #16a34a;
  --overlay:     rgba(0,0,0,.45);

  /* shape */
  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;
  --header-h:  52px;

  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

body { min-height: 100dvh; }

/* ── Typography helpers ──────────────────────────────────────────────────────── */
.label {
  font-size: 11px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint);
}
.heading-lg { font-size: 22px; font-weight: 500; letter-spacing: -.03em; }
.heading-sm { font-size: 15px; font-weight: 500; letter-spacing: -.02em; }
.hint { font-size: 12px; color: var(--text-muted); line-height: 1.6; }

/* ── Header ──────────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
  height: 100%; display: flex; align-items: center; gap: 0;
}
.header-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: -.02em;
  text-decoration: none; color: var(--text); margin-right: 32px;
}
.brand-icon {
  width: 22px; height: 22px; background: var(--text);
  border-radius: 5px; display: flex; align-items: center; justify-content: center;
}
.brand-icon svg { display: block; }
.header-nav { display: flex; gap: 0; flex: 1; }
.nav-btn {
  background: none; border: none; cursor: pointer;
  padding: 0 14px; height: var(--header-h);
  font-size: 13.5px; font-weight: 400; color: var(--text-muted);
  transition: color .12s; position: relative; letter-spacing: -.01em;
}
.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--text); font-weight: 500; }
.nav-btn.active::after {
  content: ''; position: absolute; bottom: 0; left: 14px; right: 14px;
  height: 1.5px; background: var(--text); border-radius: 2px;
}
.header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.user-email { font-size: 12px; color: var(--text-faint); }

/* ── Main ────────────────────────────────────────────────────────────────────── */
#main-content { min-height: calc(100dvh - var(--header-h)); }
.page { max-width: 1120px; margin: 0 auto; padding: 40px 24px; }
.page-sm { max-width: 560px; margin: 0 auto; padding: 40px 24px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: background .12s, border-color .12s, color .12s;
  text-decoration: none; white-space: nowrap; letter-spacing: -.01em; line-height: 1;
}
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  background: var(--bg); color: var(--text); border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost {
  background: transparent; color: var(--text-muted); border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger {
  background: transparent; color: var(--destructive); border-color: var(--border);
}
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
.btn-shake { animation: shake .35s ease; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.field input, .field select {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text); background: var(--bg);
  transition: border-color .12s, box-shadow .12s; outline: none;
  font-family: inherit; letter-spacing: -.01em;
}
.field input:focus, .field select:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 2px rgba(10,10,10,.08);
}

/* ── Auth ────────────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg-subtle);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px 32px;
}
.auth-logo {
  display: flex; align-items: center; gap: 8px; margin-bottom: 28px;
  font-size: 14px; font-weight: 600; letter-spacing: -.02em;
}
.auth-logo .brand-icon { width: 20px; height: 20px; }
.auth-title { font-size: 18px; font-weight: 500; letter-spacing: -.03em; margin-bottom: 4px; }
.auth-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-msg {
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12px;
  border: 1px solid; display: none;
}
.auth-msg.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.auth-msg.info  { background: #f0f9ff; color: #0369a1; border-color: #bae6fd; }
.auth-switch { margin-top: 18px; text-align: center; font-size: 12px; color: var(--text-muted); }
.text-link { background: none; border: none; cursor: pointer; color: var(--text); font-size: inherit; text-decoration: underline; padding: 0; }

/* ── Page header ─────────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 32px; flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 500; letter-spacing: -.03em; }
.page-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; letter-spacing: -.01em; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Section divider ─────────────────────────────────────────────────────────── */
.section-label {
  font-size: 11px; font-weight: 500; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-faint);
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

/* ── Category pills ──────────────────────────────────────────────────────────── */
.cat-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 24px; }
.pill {
  padding: 5px 12px; border-radius: 100px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-muted);
  cursor: pointer; transition: all .12s; letter-spacing: -.01em;
}
.pill:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.pill-active { background: var(--text); color: #fff; border-color: var(--text); }

/* ── Catalog / library grid ──────────────────────────────────────────────────── */
.mockup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.mockup-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: border-color .12s;
  background: var(--bg); position: relative; user-select: none;
}
.mockup-card:hover { border-color: var(--border-strong); }
.mockup-card.selected { border-color: var(--text); border-width: 1.5px; }
.mockup-card.selected .card-check { opacity: 1; }

.card-thumb-wrap {
  aspect-ratio: 4/5; background: var(--bg-subtle); overflow: hidden; position: relative;
}
.card-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-check {
  position: absolute; top: 8px; right: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--text); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .12s;
}
.card-check svg { display: block; }
.card-badge {
  position: absolute; bottom: 8px; left: 8px;
  font-size: 10px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
  background: rgba(255,255,255,.92); color: var(--text-muted);
  padding: 2px 7px; border-radius: 100px; border: 1px solid var(--border);
}
.card-body { padding: 10px 12px; }
.card-name { font-size: 12.5px; font-weight: 500; display: block; letter-spacing: -.01em; }
.card-category { font-size: 11px; color: var(--text-faint); display: block; margin-top: 1px; }
.card-actions { display: flex; gap: 4px; margin-top: 8px; }

/* Empty / loading state */
.state-empty, .state-loading {
  grid-column: 1/-1; padding: 64px 24px; text-align: center;
  color: var(--text-muted); font-size: 13px;
}

/* ── Warp editor ─────────────────────────────────────────────────────────────── */
.editor-layout {
  display: grid; grid-template-columns: 260px 1fr; gap: 32px; align-items: start;
}
@media (max-width: 720px) { .editor-layout { grid-template-columns: 1fr; } }
.editor-sidebar { display: flex; flex-direction: column; gap: 24px; }
.editor-group { display: flex; flex-direction: column; gap: 8px; }
.editor-actions { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }
.point-list { display: flex; flex-direction: column; gap: 3px; }
.point-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; padding: 3px 0;
}
.point-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color, #0a0a0a); flex-shrink: 0; }
.point-label { font-weight: 500; width: 22px; }
.point-coords { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.editor-canvas-wrap {
  background: #111; border-radius: var(--radius); overflow: hidden;
  min-height: 280px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
#ed-canvas { display: none; max-width: 100%; max-height: 68vh; cursor: crosshair; }
.canvas-placeholder {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 280px;
}
.canvas-placeholder-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: #555; text-align: center; padding: 32px; font-size: 13px;
}

/* ── Batch / generate view ───────────────────────────────────────────────────── */
.generate-layout {
  display: grid; grid-template-columns: 280px 1fr; gap: 32px; align-items: start;
}
@media (max-width: 760px) { .generate-layout { grid-template-columns: 1fr; } }
.generate-sidebar { display: flex; flex-direction: column; gap: 20px; }

.mockup-checklist {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 360px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 4px;
}
.checklist-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .1s;
}
.checklist-row:hover { background: var(--bg-hover); }
.checklist-row input { flex-shrink: 0; accent-color: var(--text); width: 14px; height: 14px; }
.checklist-thumb {
  width: 32px; height: 32px; border-radius: 4px; object-fit: cover;
  background: var(--border); flex-shrink: 0;
}
.checklist-name { font-size: 12.5px; letter-spacing: -.01em; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checklist-tag {
  font-size: 9.5px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-faint); flex-shrink: 0;
}

.drop-zone {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 22px 16px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; text-align: center;
  font-size: 12px; color: var(--text-muted);
  transition: border-color .15s, background .15s; cursor: pointer;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--text); background: var(--bg-hover); }
.drop-zone.has-file { border-color: var(--success); border-style: solid; color: var(--success); }

/* Progress list */
.progress-list { display: flex; flex-direction: column; gap: 6px; }
.progress-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.prog-name { font-weight: 500; letter-spacing: -.01em; }
.prog-status { font-size: 11px; color: var(--text-faint); }
.prog-status.running { color: var(--text-muted); }
.prog-status.done { color: var(--success); }
.prog-status.error { color: var(--destructive); }

/* Results */
.results-wrap { display: flex; flex-direction: column; gap: 14px; }
.results-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted);
}
.results-grid-inner {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
}
.result-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.result-img { width: 100%; display: block; background: var(--bg-subtle); }
.result-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; gap: 8px;
}
.result-name { font-size: 12px; font-weight: 500; letter-spacing: -.01em; }
.result-hint { font-size: 11px; color: var(--text-faint); padding: 0 12px 8px; text-align: center; }
.results-placeholder {
  min-height: 260px; border: 1px dashed var(--border);
  border-radius: var(--radius); display: flex;
  align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-faint);
}

/* ── Admin table ─────────────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left; padding: 8px 12px; font-size: 11px; font-weight: 500;
  letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint);
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg-subtle); }
.admin-thumb-cell img {
  width: 40px; height: 40px; object-fit: cover; border-radius: 4px;
  background: var(--bg-subtle); display: block;
}
.admin-name { font-weight: 500; letter-spacing: -.01em; }
.admin-cat { color: var(--text-faint); font-size: 12px; }

/* ── Billing ─────────────────────────────────────────────────────────────────── */
.billing-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--border); gap: 16px;
}
.billing-row-label { font-size: 12px; color: var(--text-faint); font-weight: 500; letter-spacing:.02em; text-transform:uppercase; width: 80px; flex-shrink:0; }
.billing-row-value { display: flex; align-items: center; }
.plan-badge {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 100px; border: 1px solid;
}
.plan-badge-free { color: var(--text-muted); border-color: var(--border-strong); background: var(--bg-subtle); }
.plan-badge-pro  { color: #fff; border-color: var(--text); background: var(--text); }
.credits-count   { font-size: 20px; font-weight: 500; letter-spacing: -.03em; }
.billing-card {
  display: flex; align-items: flex-start; gap: 20px;
  padding: 20px 24px; border: 1px solid var(--border); border-radius: var(--radius);
}
.billing-card-title { font-size: 14px; font-weight: 500; letter-spacing: -.02em; margin-bottom: 4px; }
.billing-card-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.6; max-width: 340px; }
.billing-card-price { font-size: 18px; font-weight: 500; letter-spacing: -.03em; margin-top: 10px; }
.billing-card-price span { font-size: 12px; font-weight: 400; color: var(--text-muted); }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: var(--radius-sm); font-size: 12.5px;
  font-weight: 500; background: var(--text); color: #fff;
  opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s;
  pointer-events: auto; max-width: 300px; letter-spacing: -.01em;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.success { background: #14532d; }
.toast.error   { background: #7f1d1d; }

/* ── Admin tabs ──────────────────────────────────────────────────────────────── */
.admin-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.admin-tab {
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  padding: 8px 14px; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.admin-tab:hover  { color: var(--text); }
.admin-tab.active { color: var(--text); border-bottom-color: var(--text); }

/* ── Referral dashboard stat cards ──────────────────────────────────────────── */
.ref-stat { border: 1px solid var(--border); border-radius: 8px; padding: 20px 24px; }
.ref-stat-value { font-size: 28px; font-weight: 600; letter-spacing: -.03em; }
.ref-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Mobile header ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .app-header { height: auto; }
  .header-inner {
    flex-wrap: wrap;
    padding: 0 16px;
    gap: 0;
  }
  .header-brand {
    margin-right: auto;
    height: 48px;
  }
  .header-right {
    height: 48px;
    margin-left: 0;
  }
  .header-nav {
    width: 100%;
    overflow-x: auto;
    border-top: 1px solid var(--border);
    scrollbar-width: none;
  }
  .header-nav::-webkit-scrollbar { display: none; }
  .nav-btn {
    height: 40px;
    padding: 0 12px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .nav-btn.active::after {
    bottom: 0; left: 12px; right: 12px;
  }
  #main-content { min-height: calc(100dvh - 88px); }
  .page { padding: 24px 16px; }
  .user-email { display: none; }
}
