:root {
  --bg: #08090d;
  --surface: #11131c;
  --surface-2: #181b28;
  --border: #252a3d;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #ff5a1f;
  --accent-2: #6c5ce7;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

.ambient-glow {
  position: fixed;
  inset: -20vh -10vw auto;
  height: 55vh;
  background: radial-gradient(circle at 20% 20%, rgba(255, 90, 31, 0.14), transparent 45%),
              radial-gradient(circle at 80% 10%, rgba(108, 92, 231, 0.16), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(8, 9, 13, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-icon {
  width: 38px;
  height: 38px;
}

.brand-name {
  font-family: "Space Grotesk", sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.module-tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--accent), #ff7847);
  color: #fff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(255, 90, 31, 0.45);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.credit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.credit-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-outline:hover {
  border-color: #475569;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-2), #8b5cf6);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

.hero-strip {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.hero-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.hero-strip h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(22px, 2.8vw, 32px);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.hero-strip p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 720px;
}

.hero-stats {
  display: flex;
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px;
  min-width: 140px;
}

.stat-val {
  font-family: "Space Grotesk", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.stat-lbl {
  font-size: 11px;
  color: var(--muted);
}

.studio-grid {
  display: grid;
  grid-template-columns: 320px minmax(340px, 1fr) minmax(340px, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 17px;
}

.pill-muted {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.cost-badge {
  background: rgba(255, 90, 31, 0.15);
  color: #ff885b;
  border: 1px solid rgba(255, 90, 31, 0.4);
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 620px;
  overflow-y: auto;
}

.tpl-card {
  text-align: left;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.tpl-card:hover {
  border-color: #475569;
  transform: translateY(-1px);
}

.tpl-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 90, 31, 0.4);
}

.tpl-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.tpl-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.tpl-cost {
  font-size: 11px;
  font-weight: 700;
  color: #fbbf24;
}

.tpl-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 3px;
}

.tpl-desc {
  font-size: 12px;
  color: var(--muted);
}

.template-desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.field-group {
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed #3b425c;
  background: #0c0e15;
  border-radius: 14px;
  min-height: 150px;
  padding: 14px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s ease;
}

.dropzone:hover {
  border-color: var(--accent);
}

.upload-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 8px;
  border-radius: 10px;
  background: rgba(255, 90, 31, 0.16);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
}

.upload-title {
  font-size: 13px;
  font-weight: 600;
}

.upload-sub {
  font-size: 11px;
  color: var(--muted);
}

.uploaded-preview {
  max-height: 210px;
  max-width: 100%;
  border-radius: 10px;
  object-fit: contain;
}

.upload-status {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 12px;
}

.chip-grid, .chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: rgba(255, 90, 31, 0.16);
  color: #fff;
  border-color: var(--accent);
}

.controls-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
}

textarea, input[type="email"], input[type="text"] {
  width: 100%;
  background: #0c0e15;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}

textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary-lg {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #ff7a3d);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-primary-lg:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.error-banner {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  font-size: 12px;
}

.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.status-pill.ok { background: rgba(16, 185, 129, 0.16); color: #34d399; }
.status-pill.run { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }
.status-pill.err { background: rgba(239, 68, 68, 0.16); color: #f87171; }

.stage-box {
  min-height: 410px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #090b10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.stage-empty, .stage-loading {
  text-align: center;
  max-width: 300px;
  color: var(--muted);
  font-size: 13px;
}

.stage-ring {
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 2px dashed #334155;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid #252a3d;
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar {
  height: 6px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-fill {
  height: 100%;
  width: 15%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s ease;
}

.stage-media {
  max-width: 100%;
  max-height: 460px;
  border-radius: 10px;
  object-fit: contain;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.gal-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gal-thumb {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: #090b10;
}

.gal-meta {
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 28px 36px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.footer-links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 8, 0.78);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  width: 100%;
  max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-sm {
  max-width: 460px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-head h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.icon-close {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
}

.modal-sub {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted);
}

.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.pack-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pack-card.popular {
  border-color: var(--accent);
}

.pack-price {
  font-family: "Space Grotesk", sans-serif;
  font-size: 22px;
  font-weight: 700;
}

.pack-cr {
  color: #fbbf24;
  font-weight: 700;
  font-size: 13px;
}

.web2app-box {
  background: rgba(108, 92, 231, 0.12);
  border: 1px solid rgba(108, 92, 231, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.web2app-box p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.auth-current {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
  .template-list {
    max-height: none;
  }
}
