:root {
  --bg: #0b0a10;
  --bg2: #131118;
  --card: #18151f;
  --line: #2a2535;
  --text: #f0eef6;
  --muted: #a09aae;
  --accent: #b57bff;
  --accent2: #ff6ec7;
  --radius: 16px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(1100px 500px at 20% -10%, #241a3d 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.center { text-align: center; }

.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 64px);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(11, 10, 16, 0.65);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: 0.12em; color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 14px; }
.balance { font-size: 14px; color: var(--muted); }
.balance b { color: var(--accent); font-size: 16px; }
.btn-mini {
  cursor: pointer; font-size: 13px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--text);
  transition: border-color .2s;
}
.btn-mini:hover { border-color: var(--accent); }
.btn-accent { border-color: var(--accent); color: var(--text); }
.btn-accent:hover { background: rgba(181,123,255,0.12); }
.user-chip { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.user-chip b { color: var(--text); }

/* auth modal */
.modal-overlay {
  position: absolute; inset: 0; min-height: 100vh; z-index: 50;
  background: rgba(5, 4, 10, 0.72); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 40px;
}
.modal {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 26px 24px;
  position: relative; box-shadow: 0 40px 100px -30px rgba(0,0,0,0.9);
}
.modal-close {
  position: absolute; top: 14px; right: 16px; background: none; border: none;
  color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-brand { text-align: center; font-weight: 800; letter-spacing: .1em; color: var(--accent); margin-bottom: 18px; }
.tabs { display: flex; background: var(--bg2); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.tab {
  flex: 1; cursor: pointer; background: none; border: none; color: var(--muted);
  padding: 9px; border-radius: 7px; font-size: 14px; font-family: inherit; font-weight: 500; transition: all .15s;
}
.tab.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.social { display: flex; flex-direction: column; gap: 10px; align-items: center; min-height: 20px; }
.social:empty { display: none; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .field { margin: 0; }
.auth-form .field input {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  padding: 12px 14px; border-radius: 10px; font-size: 15px; font-family: inherit;
}
.auth-form .field input:focus { outline: none; border-color: var(--accent); }
.captcha-row { display: flex; align-items: center; gap: 10px; }
.captcha-img { height: 48px; width: 145px; border-radius: 8px; background: #ece9f3; flex-shrink: 0; }
.captcha-refresh {
  cursor: pointer; background: var(--bg2); border: 1px solid var(--line); color: var(--muted);
  width: 38px; height: 38px; border-radius: 8px; font-size: 16px; flex-shrink: 0;
}
.captcha-refresh:hover { border-color: var(--accent); color: var(--text); }
.captcha-row input { flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--line); color: var(--text); padding: 12px 12px; border-radius: 10px; font-size: 15px; font-family: inherit; }
.captcha-row input:focus { outline: none; border-color: var(--accent); }
.checkbox-row { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); line-height: 1.45; cursor: pointer; }
.checkbox-row input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.checkbox-row a { color: var(--accent); text-decoration: underline; }
.auth-err { font-size: 13px; color: #ff7b7b; min-height: 16px; text-align: center; margin: 0; }
.auth-err.ok { color: var(--accent); }
.key-advanced { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.key-advanced summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.key-advanced .muted { font-size: 12px; margin: 10px 0; }

.hero-slim { text-align: center; padding: clamp(36px, 6vw, 70px) 20px 10px; }
.hero-slim h1 { font-size: clamp(32px, 5vw, 56px); font-weight: 800; }
.hero-slim h1 span { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-slim p { max-width: 60ch; margin: 16px auto 0; font-size: 17px; }

.studio {
  display: grid; grid-template-columns: 420px 1fr; gap: 32px; align-items: start;
  max-width: 1080px; margin: 0 auto; padding: clamp(28px, 5vw, 56px) clamp(20px, 5vw, 64px);
}
.gen-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.field span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 8px; }
.field textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  padding: 13px 14px; border-radius: 10px; font-size: 15px; font-family: inherit; resize: vertical;
}
.field textarea:focus { outline: none; border-color: var(--accent); }
.opts { margin: 18px 0; display: flex; flex-direction: column; gap: 14px; }
.opt-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  cursor: pointer; font-size: 13px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--muted); transition: all .15s;
}
.chip-btn.on { border-color: var(--accent); color: var(--text); background: rgba(181,123,255,0.12); }

.btn-primary {
  display: inline-block; cursor: pointer; border: none;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #140a1f; font-weight: 700; font-size: 15px;
  padding: 14px 26px; border-radius: 999px; transition: transform .15s, filter .2s;
}
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn-primary.big { width: 100%; padding: 16px; font-size: 17px; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost {
  cursor: pointer; background: transparent; color: var(--text); text-align: center;
  border: 1px solid var(--line); padding: 12px 18px; border-radius: 999px;
  font-size: 14px; flex: 1; transition: border-color .2s, background .2s;
}
.btn-ghost:hover { border-color: var(--accent); background: rgba(181,123,255,0.06); }

.pay-status { font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }
.pay-status.err { color: #ff7b7b; }
.pay-status.ok { color: var(--accent); }

.result-panel { display: flex; flex-direction: column; gap: 14px; }
.result-frame {
  border-radius: var(--radius); overflow: hidden; background: var(--bg2);
  border: 1px solid var(--line); min-height: 420px;
  display: grid; place-items: center; position: relative;
}
.result-frame img { display: block; width: 100%; height: auto; }
.placeholder { color: var(--muted); font-size: 14px; padding: 40px; text-align: center; }
.placeholder.working::after {
  content: ''; display: block; margin: 18px auto 0; width: 28px; height: 28px;
  border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-actions { display: flex; gap: 10px; }

.gallery, .packs { max-width: 1080px; margin: 0 auto; padding: clamp(28px, 5vw, 48px) clamp(20px, 5vw, 64px); scroll-margin-top: 80px; }
.gallery h2, .packs h2 { font-size: 28px; text-align: center; margin-bottom: 8px; }
.packs .muted { margin-bottom: 26px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 22px; }
.grid .cell { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.grid .cell img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.grid .cell .cap { font-size: 11px; color: var(--muted); padding: 8px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; max-width: 760px; margin: 0 auto; }
.pack {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 22px; text-align: center; transition: border-color .2s, transform .2s;
}
.pack:hover { border-color: var(--accent); transform: translateY(-3px); }
.pack.hot { border-color: var(--accent2); position: relative; }
.pack.hot::before {
  content: 'Most popular'; position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  font-size: 11px; background: var(--accent2); color: #140a1f; font-weight: 700;
  padding: 3px 12px; border-radius: 999px;
}
.pack h3 { font-size: 17px; }
.pack .amount { font-size: 36px; font-weight: 800; margin: 10px 0 2px; color: var(--accent); }
.pack .amount small { font-size: 14px; color: var(--muted); font-weight: 400; }
.pack .usd { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.pack .per { font-size: 11px; color: var(--muted); margin-top: 10px; }

.account-box { max-width: 720px; margin: 0 auto; padding: 20px clamp(20px, 5vw, 64px) 40px; }
.account-box h3 { font-size: 16px; margin-bottom: 6px; }
.account-box .muted { font-size: 13px; }
.auth-row { display: flex; gap: 12px; align-items: center; margin-top: 14px; flex-wrap: wrap; min-height: 40px; }
.apple-btn {
  cursor: pointer; background: #000; color: #fff; border: 1px solid #333;
  font-size: 15px; font-weight: 500; padding: 10px 22px; border-radius: 8px;
  font-family: inherit; transition: background .2s;
}
.apple-btn:hover { background: #1a1a1a; }
.signout-btn { margin-left: 10px; }
.key-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.key-row code {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 13px; font-size: 12px; color: var(--accent); user-select: all;
}

footer { border-top: 1px solid var(--line); padding: 30px clamp(20px, 5vw, 64px); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 13px; }
footer .muted { max-width: 52ch; }
.footer-links { display: flex; gap: 18px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

/* legal pages */
.legal { max-width: 760px; margin: 0 auto; padding: 40px clamp(20px, 5vw, 40px) 80px; }
.legal h1 { font-size: 30px; margin-bottom: 6px; }
.legal .updated { color: var(--muted); font-size: 13px; margin-bottom: 32px; }
.legal h2 { font-size: 19px; margin: 30px 0 10px; }
.legal p, .legal li { color: var(--text); font-size: 15px; line-height: 1.7; }
.legal ul { margin: 8px 0 8px 22px; }
.legal li { margin-bottom: 6px; }
.legal a { color: var(--accent); text-decoration: underline; }
.legal .note { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; font-size: 14px; color: var(--muted); margin: 24px 0; }

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; }
  .pack-grid { grid-template-columns: 1fr; max-width: 340px; }
}
