:root {
  --bg: #07111f;
  --bg-elevated: rgba(10, 21, 37, 0.78);
  --panel: rgba(10, 22, 38, 0.84);
  --panel-border: rgba(124, 176, 255, 0.18);
  --text: #f3f7fd;
  --muted: #9fb2cb;
  --cyan: #57d8ff;
  --blue: #4285ff;
  --teal: #3ef0c4;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(66, 133, 255, 0.2), transparent 32%),
    radial-gradient(circle at top right, rgba(62, 240, 196, 0.12), transparent 28%),
    linear-gradient(180deg, #081120 0%, #050b15 100%);
}

img {
  max-width: 100%;
  display: block;
  background:
    linear-gradient(135deg, rgba(66, 133, 255, 0.12), rgba(62, 240, 196, 0.06));
  transition: opacity 0.35s ease, transform 0.35s ease;
}

img:not([src]),
img[src=""] {
  min-height: 220px;
  visibility: hidden;
}

button,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.topbar,
.hero,
.workspace,
.gallery,
.styles {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  padding: 16px 20px;
  background: rgba(8, 18, 31, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.topbar-nav {
  display: flex;
  gap: 24px;
}

.topbar-nav a,
.topbar-cta,
.result-actions button,
.upload-box button {
  color: var(--text);
  text-decoration: none;
}

.topbar-nav a {
  color: var(--muted);
}

.topbar-cta,
.result-actions button,
.upload-box button,
.toggle-btn,
.thumb-card,
.style-card,
.prompt-chip {
  border: 0;
  cursor: pointer;
}

.topbar-cta {
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #03111d;
  font-weight: 800;
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  align-items: center;
  margin-bottom: 32px;
}

.hero-copy,
.hero-preview-card,
.panel,
.gallery-card,
.style-card {
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-copy {
  padding: 40px;
  border-radius: var(--radius-xl);
}

.eyebrow,
.section-kicker {
  display: inline-block;
  color: var(--cyan);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero-copy h1,
.section-heading h2,
.panel-heading h2 {
  margin: 10px 0 0;
  line-height: 1.02;
}

.hero-copy h1 {
  font-size: clamp(2.8rem, 5vw, 5rem);
  max-width: 12ch;
}

.hero-copy p {
  max-width: 58ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.hero-metrics div {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.hero-metrics strong {
  display: block;
  font-size: 1.6rem;
}

.hero-metrics span {
  color: var(--muted);
  font-size: 0.95rem;
}

.hero-preview-card {
  position: relative;
  overflow: hidden;
  border-radius: 30px;
  min-height: 520px;
}

.hero-preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-preview-badge {
  position: absolute;
  left: 20px;
  bottom: 20px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(5, 11, 21, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr);
  gap: 24px;
  margin-bottom: 36px;
}

.panel {
  padding: 24px;
  border-radius: var(--radius-xl);
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.panel-heading h2,
.section-heading h2 {
  font-size: clamp(1.6rem, 2vw, 2.3rem);
}

.status-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(62, 240, 196, 0.12);
  color: var(--teal);
  border: 1px solid rgba(62, 240, 196, 0.24);
}

.field-label,
.field span,
.option-title,
.range-field span,
.prompt-summary span {
  display: block;
  margin-bottom: 12px;
  color: #dfe9f8;
  font-weight: 600;
}

textarea,
select {
  width: 100%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}

textarea {
  resize: vertical;
  padding: 18px;
  line-height: 1.6;
  min-height: 164px;
}

select {
  padding: 14px 16px;
}

.chip-row,
.toggle-row,
.thumb-strip,
.style-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.prompt-chip,
.toggle-btn {
  padding: 11px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid transparent;
}

.prompt-chip:hover,
.toggle-btn:hover,
.style-card:hover,
.thumb-card:hover {
  border-color: rgba(87, 216, 255, 0.42);
}

.field-grid,
.slider-grid,
.gallery-grid,
.style-grid {
  display: grid;
  gap: 16px;
}

.field-grid,
.slider-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 20px;
}

.option-group,
.slider-grid,
.upload-box,
.generate-button,
.result-stage,
.prompt-summary,
.thumb-strip {
  margin-top: 20px;
}

input[type="range"] {
  width: 100%;
}

.upload-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.16);
}

.upload-box p {
  margin: 6px 0 0;
  color: var(--muted);
}

.upload-box button,
.result-actions button {
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.generate-button {
  position: relative;
  width: 100%;
  padding: 18px 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, #73e1ff 0%, #4374ff 50%, #7c5cff 100%);
  color: #041320;
  text-align: left;
  font-weight: 800;
  box-shadow: 0 24px 60px rgba(67, 116, 255, 0.35);
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.generate-button:active:not(.is-loading) {
  transform: translateY(1px);
}

.generate-button.is-loading::after {
  content: "";
  position: absolute;
  right: 22px;
  top: 50%;
  width: 22px;
  height: 22px;
  margin-top: -11px;
  border: 3px solid rgba(4, 19, 32, 0.22);
  border-top-color: #041320;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.generate-button small {
  display: block;
  margin-top: 6px;
  opacity: 0.8;
}

.generate-button.is-loading {
  opacity: 0.8;
  pointer-events: none;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.result-stage {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  min-height: 560px;
  background: rgba(255, 255, 255, 0.04);
}

.result-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-overlay {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.result-overlay span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(5, 11, 21, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.prompt-summary {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
}

.prompt-summary p,
.gallery-card p,
.style-card span {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.thumb-card {
  width: calc(33.333% - 8px);
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  background: transparent;
  border: 2px solid transparent;
}

.thumb-card img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.thumb-card.is-active,
.toggle-btn.is-active,
.style-card.is-selected {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(87, 216, 255, 0.2) inset;
}

/* Smooth transitions for interactive controls */
.thumb-card,
.toggle-btn,
.style-card,
.prompt-chip,
.topbar-cta,
.result-actions button,
.upload-box button {
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.12s ease;
}

.thumb-card:active,
.toggle-btn:active,
.style-card:active,
.prompt-chip:active {
  transform: translateY(1px);
}

/* Focus-visible styles for keyboard navigation */
button:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* Fade images in when they swap */
.result-stage img,
.hero-preview-card img {
  transition: opacity 0.35s ease;
}

/* Result error message */
.result-error {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.28);
  color: #ff9a9a;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Safety notices */
.safety-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(62, 240, 196, 0.08);
  border: 1px solid rgba(62, 240, 196, 0.18);
  color: var(--teal);
  font-size: 0.92rem;
  line-height: 1.5;
}

.safety-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(87, 216, 255, 0.12), rgba(62, 240, 196, 0.1));
  border: 1px solid rgba(87, 216, 255, 0.22);
  color: var(--text);
  font-size: 0.98rem;
}

.safety-banner strong {
  color: var(--cyan);
  font-weight: 700;
}

.safety-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.gallery,
.styles {
  margin-top: 30px;
}

.gallery-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gallery-card {
  overflow: hidden;
  border-radius: 24px;
}

.gallery-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.gallery-card div {
  padding: 20px;
}

.gallery-card h3,
.style-card strong {
  margin: 0 0 8px;
}

.style-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.style-card {
  padding: 22px;
  border-radius: 22px;
  text-align: left;
  color: var(--text);
}

@media (max-width: 1100px) {
  .hero,
  .workspace,
  .gallery-grid,
  .style-grid {
    grid-template-columns: 1fr;
  }

  .hero-preview-card,
  .result-stage {
    min-height: 420px;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 14px;
  }

  .topbar {
    flex-wrap: wrap;
    border-radius: 28px;
  }

  .topbar-nav {
    width: 100%;
    justify-content: space-between;
  }

  .hero-copy,
  .panel {
    padding: 20px;
  }

  .hero-metrics,
  .field-grid,
  .slider-grid {
    grid-template-columns: 1fr;
  }

  .upload-box,
  .panel-heading,
  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .thumb-card {
    width: calc(50% - 6px);
  }
}
