:root {
  --bg: #f5f2ec;
  --text: #09090b;
  --muted: #71717a;
  --dark: #09090b;
  --white: #ffffff;
  --border: #e4e4e7;
  --shadow: 0 24px 80px rgba(24, 24, 27, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #fff 0, var(--bg) 34%, #eee7da 100%);
}

.site-header {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: white;
  background: var(--dark);
  box-shadow: 0 12px 24px rgba(0,0,0,.18);
}
.brand-name { font-size: 20px; font-weight: 900; letter-spacing: -0.04em; }
.brand-subtitle { color: var(--muted); font-size: 12px; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.lang-btn, .top-cta, .download-btn, .primary-btn {
  border: 0;
  cursor: pointer;
  font-weight: 800;
  transition: transform .2s ease, opacity .2s ease, background .2s ease;
}
.lang-btn {
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  color: var(--dark);
}
.lang-btn.active { background: var(--dark); color: white; }
.top-cta {
  text-decoration: none;
  color: white;
  background: var(--dark);
  padding: 10px 18px;
  border-radius: 999px;
}
button:hover, .top-cta:hover { transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.page-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 48px 24px 54px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 34px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--border);
  color: #52525b;
  box-shadow: 0 10px 30px rgba(0,0,0,.06);
}

h1 {
  max-width: 760px;
  margin: 22px 0 0;
  font-size: clamp(46px, 7vw, 78px);
  line-height: 1.02;
  letter-spacing: -0.07em;
}

.hero-text {
  max-width: 660px;
  margin: 24px 0 0;
  font-size: 18px;
  line-height: 1.75;
  color: #52525b;
}

.generator-card {
  margin-top: 32px;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  border-radius: 34px;
  background: white;
  box-shadow: var(--shadow);
}

.upload-box {
  min-height: 330px;
  border: 2px dashed var(--border);
  border-radius: 26px;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 22px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.upload-box:hover { border-color: var(--dark); background: white; }
.upload-icon {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  margin: 0 auto 15px;
  border-radius: 24px;
  background: var(--dark);
  color: white;
  font-size: 30px;
}
.upload-placeholder span { display: block; margin-top: 8px; color: var(--muted); font-size: 14px; }
.uploaded-image { max-width: 94%; max-height: 260px; object-fit: contain; border-radius: 22px; box-shadow: 0 18px 35px rgba(0,0,0,.16); }
.file-name { margin-top: 14px; color: var(--muted); max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

.form-panel { display: flex; flex-direction: column; gap: 11px; }
.form-panel label span { display: block; margin-bottom: 5px; color: #71717a; font-size: 12px; font-weight: 800; }
.form-panel input {
  width: 100%;
  border: 1px solid var(--border);
  outline: 0;
  border-radius: 18px;
  padding: 13px 14px;
  background: #fafafa;
  font-size: 14px;
}
.form-panel input:focus { border-color: var(--dark); background: white; }
.primary-btn {
  width: 100%;
  margin-top: 4px;
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--dark);
  color: white;
  font-size: 15px;
}

.preview-shell {
  padding: 18px;
  border-radius: 34px;
  background: var(--dark);
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
}
.preview-header {
  padding: 2px 4px 16px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.preview-header small { display: block; margin-top: 4px; color: #a1a1aa; }
.download-btn { padding: 11px 15px; border-radius: 999px; background: white; color: var(--dark); }

.ad-preview {
  aspect-ratio: 4 / 5;
  /* Keep the complete generated ad visible inside the preview.
     The old fixed min-height plus large inner content could clip the bottom card. */
  min-height: 0;
  border-radius: 26px;
  color: white;
  overflow: hidden;
  position: relative;
  padding: clamp(16px, 2vw, 28px);
}
.gradient-1 { background: linear-gradient(135deg, #18181b, #27272a, #0c0a09); }
.gradient-2 { background: linear-gradient(135deg, #111827, #1e1b4b, #020617); }
.gradient-3 { background: linear-gradient(135deg, #4c0519, #18181b, #020617); }
.gradient-4 { background: linear-gradient(135deg, #052e16, #0f172a, #09090b); }
.gradient-5 { background: linear-gradient(135deg, #451a03, #1c1917, #09090b); }

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #a1a1aa;
}
.empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty-state strong { color: white; font-size: 20px; }
.empty-state p { max-width: 310px; line-height: 1.6; }

.ad-content {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(150px, 1fr) auto;
  gap: clamp(10px, 1.4vw, 18px);
  min-height: 0;
}
.ad-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.ad-topline strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-badge { padding: 8px 13px; border-radius: 999px; background: rgba(255,255,255,.14); backdrop-filter: blur(12px); font-size: 12px; font-weight: 800; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  min-height: 0;
  pointer-events: none;
}
.product-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(0,0,0,.18) 0%, rgba(0,0,0,.12) 42%, rgba(0,0,0,.58) 100%);
}
.glow { position: absolute; top: 12%; left: 18%; width: 62%; aspect-ratio: 1; border-radius: 999px; background: rgba(255,255,255,.18); filter: blur(44px); }
#adProductImage {
  position: absolute;
  z-index: 1;
  top: 10%;
  right: 5%;
  width: min(62%, 430px);
  height: 55%;
  object-fit: cover;
  object-position: center;
  border-radius: 28px;
  opacity: .72;
  box-shadow: 0 22px 58px rgba(0,0,0,.38);
}
.copy-card {
  position: relative;
  z-index: 3;
  align-self: end;
  padding: clamp(16px, 2vw, 23px);
  border-radius: 28px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(14px);
}
.copy-card h2 { margin: 0; font-size: clamp(24px, 3.1vw, 38px); line-height: 1.04; letter-spacing: -0.045em; }
.copy-card p { margin: 12px 0 0; color: rgba(255,255,255,.74); line-height: 1.45; font-size: clamp(13px, 1.35vw, 16px); }
.ad-bullets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.ad-bullets span { padding: 6px 9px; border-radius: 999px; background: rgba(255,255,255,.14); font-size: 11px; font-weight: 800; }
.ad-cta { margin-top: 14px; padding: 11px 18px; border: 0; border-radius: 16px; background: white; color: var(--dark); font-weight: 950; }

.site-footer { text-align: center; color: #71717a; padding: 0 24px 36px; }

@media (max-width: 980px) {
  .page-shell { grid-template-columns: 1fr; padding-top: 24px; }
  
}

@media (max-width: 640px) {
  .site-header { align-items: flex-start; }
  .generator-card { grid-template-columns: 1fr; }
  .preview-header { align-items: flex-start; flex-direction: column; }
  .download-btn { width: 100%; }
  h1 { font-size: 44px; }
  .ad-preview { padding: 16px; }
  #adProductImage { width: 76%; height: 48%; right: 50%; transform: translateX(50%); border-radius: 22px; opacity: .56; }
  .copy-card h2 { font-size: 26px; }
}

@media (min-width: 1180px) {
  .preview-shell { position: sticky; top: 18px; align-self: start; }
}

body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 9, 11, .38);
  backdrop-filter: blur(18px);
}

.signup-modal {
  width: min(520px, 100%);
  position: relative;
  overflow: hidden;
  border-radius: 34px;
  color: white;
  background: linear-gradient(135deg, rgba(255,255,255,.20), rgba(255,255,255,.08));
  border: 1px solid rgba(255,255,255,.30);
  box-shadow: 0 32px 90px rgba(0,0,0,.34);
  backdrop-filter: blur(28px) saturate(150%);
}

.modal-glow {
  position: absolute;
  width: 340px;
  height: 340px;
  right: -120px;
  top: -140px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255,255,255,.42), rgba(129,140,248,.24), transparent 70%);
  pointer-events: none;
}

.modal-content {
  position: relative;
  z-index: 1;
  padding: 34px;
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  color: white;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.modal-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.20);
  font-size: 13px;
  font-weight: 800;
}

.signup-modal h2 {
  margin: 18px 0 0;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.04;
  letter-spacing: -0.055em;
}

.signup-modal p {
  margin: 12px 0 0;
  color: rgba(255,255,255,.74);
  line-height: 1.6;
}

.signup-form {
  margin-top: 24px;
  display: grid;
  gap: 14px;
}

.signup-form label span {
  display: block;
  margin-bottom: 7px;
  color: rgba(255,255,255,.78);
  font-size: 12px;
  font-weight: 900;
}

.signup-form input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.24);
  outline: none;
  border-radius: 18px;
  padding: 14px 15px;
  color: white;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
  font-size: 15px;
}

.signup-form input:focus {
  border-color: rgba(255,255,255,.72);
  background: rgba(255,255,255,.18);
}

.signup-submit {
  margin-top: 6px;
  background: white;
  color: var(--dark);
}

#signupNote {
  display: block;
  color: rgba(255,255,255,.62);
  text-align: center;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .modal-content { padding: 28px 20px 22px; }
  .signup-modal { border-radius: 28px; }
}
