:root {
  --bg: #0b0a1a;
  --panel: rgba(24, 20, 48, 0.72);
  --border: rgba(255, 120, 190, 0.18);
  --pink: #ff5fa2;
  --orange: #ff9e5f;
  --purple: #9d5fff;
  --text: #f4eefb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-wrap {
  min-height: 100vh;
  position: relative;
  background:
    radial-gradient(circle at 15% 10%, rgba(157,95,255,0.18), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(255,95,162,0.18), transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(255,158,95,0.12), transparent 50%);
}

/* animated background blobs */
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
}
.blob1 { width: 380px; height: 380px; background: var(--purple); top: -80px; left: -60px; animation: drift 18s ease-in-out infinite; }
.blob2 { width: 420px; height: 420px; background: var(--pink); bottom: -120px; right: -80px; animation: drift 22s ease-in-out infinite reverse; }
@keyframes drift {
  0%,100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.15); }
}

/* header */
.title {
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
  background: linear-gradient(90deg, var(--pink), var(--orange), var(--purple), var(--pink));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shift 6s linear infinite;
}
@keyframes shift { to { background-position: 300% 0; } }
.tagline {
  margin: 0.5rem auto 0;
  max-width: 34rem;
  color: #c9bce4;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  font-weight: 300;
  padding: 0 1rem;
}

/* layout */
.main-grid {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 820px) {
  .main-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.25rem;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}

/* prompt box */
.prompt-box {
  width: 100%;
  resize: vertical;
  background: rgba(10, 8, 24, 0.6);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  padding: 1rem;
  font-size: 1.05rem;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.prompt-box::placeholder { color: #8a7db0; }
.prompt-box:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255,95,162,0.18);
}

/* generate button */
.gen-btn {
  background: linear-gradient(90deg, var(--pink), var(--orange));
  color: #1a0e1e;
  font-weight: 800;
  font-size: 1.15rem;
  border: none;
  border-radius: 16px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, filter 0.2s;
  box-shadow: 0 8px 24px rgba(255,95,162,0.35);
}
.gen-btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 12px 32px rgba(255,95,162,0.5); }
.gen-btn:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.gen-btn:disabled { opacity: 0.6; cursor: wait; }

.surprise-btn {
  background: rgba(157,95,255,0.2);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 1.5rem;
  width: 56px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.surprise-btn:hover { background: rgba(157,95,255,0.4); transform: rotate(20deg) scale(1.05); }

.hint { font-size: 0.75rem; color: #9a8dbe; margin: 0.6rem 0 0; font-family: 'Space Mono', monospace; }

/* controls */
.control-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.ctl-label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: #9a8dbe; margin-bottom: 0.4rem; font-family: 'Space Mono', monospace; }

.seg { display: inline-flex; background: rgba(10,8,24,0.6); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.seg-btn { border: none; background: transparent; color: #b9abd6; padding: 0.4rem 0.85rem; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 0.9rem; transition: all 0.2s; }
.seg-on { background: linear-gradient(90deg, var(--purple), var(--pink)); color: #fff; box-shadow: 0 3px 12px rgba(157,95,255,0.4); }

.ratio-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 58px; height: 52px; background: rgba(10,8,24,0.6); border: 1px solid var(--border); border-radius: 12px; color: #b9abd6; cursor: pointer; transition: all 0.2s; }
.ratio-on { border-color: var(--pink); color: #fff; background: rgba(255,95,162,0.15); }
.ratio-glyph { font-size: 1.1rem; line-height: 1; }

.chip { background: rgba(10,8,24,0.6); border: 1px solid var(--border); border-radius: 999px; color: #c2b4de; padding: 0.35rem 0.85rem; font-size: 0.85rem; cursor: pointer; transition: all 0.18s; }
.chip:hover { border-color: var(--purple); }
.chip-on { background: linear-gradient(90deg, rgba(157,95,255,0.5), rgba(255,95,162,0.5)); color: #fff; border-color: transparent; }
.chip-hint { font-size: 0.78rem; }

.more-btn { background: none; border: none; color: var(--pink); font-size: 0.85rem; cursor: pointer; margin-top: 0.9rem; font-weight: 700; padding: 0; }
.more-btn:hover { text-decoration: underline; }

/* result panel */
.result-panel { display: flex; padding: 1rem; }
.result-card {
  width: 100%;
  min-height: 340px;
  border-radius: 16px;
  background: rgba(10,8,24,0.5);
  border: 1px dashed var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.result-img { width: 100%; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.result-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; justify-content: center; }
.act { background: rgba(157,95,255,0.18); border: 1px solid var(--border); color: #eadcff; border-radius: 10px; padding: 0.45rem 0.75rem; font-size: 0.85rem; cursor: pointer; font-weight: 700; transition: background 0.2s, transform 0.1s; }
.act:hover { background: rgba(157,95,255,0.4); }
.act:active { transform: scale(0.95); }
.result-prompt { margin-top: 0.6rem; color: #c9bce4; font-style: italic; font-size: 0.9rem; text-align: center; }

/* shimmer + spinner */
.shimmer { position: relative; overflow: hidden; }
.shimmer::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,95,162,0.12) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: sweep 1.3s infinite;
}
@keyframes sweep { to { transform: translateX(100%); } }
.spinner {
  width: 56px; height: 56px; border-radius: 50%;
  border: 5px solid rgba(255,255,255,0.12);
  border-top-color: var(--pink);
  border-right-color: var(--orange);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pop { animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pop { 0% { transform: scale(0.92); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.float { animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* gallery */
.gallery-wrap { max-width: 1100px; margin: 2rem auto 0; padding: 0 1rem; }
.gallery-title { font-size: 1.2rem; font-weight: 700; margin: 0; }
.clear-btn { background: rgba(255,95,162,0.15); border: 1px solid var(--border); color: #ffc2dd; border-radius: 10px; padding: 0.4rem 0.8rem; cursor: pointer; font-size: 0.85rem; }
.clear-btn:hover { background: rgba(255,95,162,0.3); }
.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
@media (max-width: 820px) { .gallery-grid { grid-template-columns: repeat(2, 1fr); } }
.thumb { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; cursor: pointer; border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.thumb:hover img { transform: scale(1.08); }
.thumb-overlay {
  position: absolute; inset: auto 0 0 0; padding: 0.5rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  font-size: 0.72rem; color: #eee;
  opacity: 0; transition: opacity 0.2s;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.thumb:hover .thumb-overlay { opacity: 1; }

/* footer */
.footer { text-align: center; padding: 2.5rem 1rem 2rem; color: #9a8dbe; font-size: 0.85rem; }
.footer .sep { margin: 0 0.5rem; }
.footer .remix { color: var(--pink); text-decoration: none; font-weight: 700; }
.footer .remix:hover { text-decoration: underline; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(5,3,15,0.88); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.lightbox-inner { position: relative; max-width: 560px; width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 1rem; }
.lightbox-img { width: 100%; border-radius: 14px; }
.close-btn { position: absolute; top: -14px; right: -14px; width: 38px; height: 38px; border-radius: 50%; background: var(--pink); color: #fff; border: none; font-size: 1.1rem; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.4); }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(90deg, var(--purple), var(--pink));
  color: #fff; padding: 0.7rem 1.3rem; border-radius: 999px; font-weight: 700;
  z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastin 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes toastin { from { transform: translate(-50%, 20px); opacity: 0; } }