:root {
  --bg: #0f0b16;
  --panel: #17121f;
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f5f3f7;
  --text-dim: #a89fb3;
  --accent-1: #ff4d8d;
  --accent-2: #7c3aed;
  --radius: 20px;
  --cta-height: 84px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 0%, #241a35 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: var(--cta-height);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(15, 11, 22, 0.75);
  border-bottom: 1px solid var(--panel-border);
}

.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 20px;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
}

.logo-accent {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Page layout ---------- */
.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.hero {
  text-align: center;
  padding: 20px 0 32px;
}

.hero h1 {
  font-size: 1.9rem;
  line-height: 1.25;
  margin: 0 0 12px;
}

.hero-accent {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  color: var(--text-dim);
  margin: 0;
  font-size: 0.95rem;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

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

.panel-title {
  font-size: 1rem;
  margin: 0 0 6px;
  color: var(--text);
}

.panel-hint {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0 0 14px;
}

/* ---------- Upload dropzone ---------- */
.dropzone {
  display: block;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  min-height: 220px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dropzone:hover {
  border-color: var(--accent-1);
  background: rgba(255, 77, 141, 0.05);
}

.dropzone-placeholder {
  text-align: center;
  color: var(--text-dim);
  padding: 20px;
}

.dropzone-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.dropzone-hint {
  display: block;
  font-size: 0.78rem;
  margin-top: 6px;
  opacity: 0.7;
}

.preview-image {
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
}

.hidden {
  display: none !important;
}

/* ---------- Hairstyle grid ---------- */
.style-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.style-chip {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.style-chip:hover {
  transform: translateY(-2px);
}

.style-chip.selected {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  font-weight: 600;
}

.style-loading {
  color: var(--text-dim);
  grid-column: 1 / -1;
}

.sub-title {
  font-size: 0.85rem;
  margin: 20px 0 4px;
  color: var(--text);
}

.dropzone-small {
  min-height: 90px;
}

.dropzone-small .preview-image {
  min-height: 90px;
}

.dropzone-small .dropzone-icon {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.dropzone-small .dropzone-placeholder p {
  margin: 0;
  font-size: 0.85rem;
}

.link-btn {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: none;
  color: var(--accent-1);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px;
}

/* ---------- Result ---------- */
.result-section {
  margin-top: 20px;
}

.result-box {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-placeholder {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
}

.result-compare {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: 100%;
}

.result-compare figure {
  margin: 0;
  text-align: center;
}

.result-compare img {
  width: 100%;
  border-radius: 14px;
  display: block;
}

.result-compare figcaption {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.result-meta {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.loading-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-1);
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

.error-message {
  margin-top: 12px;
  color: #ff8f8f;
  background: rgba(255, 90, 90, 0.08);
  border: 1px solid rgba(255, 90, 90, 0.25);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
}

/* ---------- CTA bar (mobile: fixed to bottom, app-like) ---------- */
.cta-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 20px;
  background: rgba(15, 11, 22, 0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--panel-border);
  z-index: 10;
}

.generate-btn {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  display: block;
  padding: 15px;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.generate-btn:active {
  transform: scale(0.98);
}

.generate-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Desktop / web layout ---------- */
@media (min-width: 860px) {
  .hero h1 {
    font-size: 2.6rem;
  }

  .workspace {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

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

  .result-compare {
    grid-template-columns: 1fr 1fr;
  }

  .cta-bar {
    position: static;
    background: transparent;
    border-top: none;
    backdrop-filter: none;
    padding: 24px 0 0;
  }

  .generate-btn {
    max-width: 320px;
  }

  body {
    padding-bottom: 0;
  }
}
