:root {
  --bg: #0e0f12;
  --panel: #17181c;
  --panel-2: #1e2024;
  --border: #2a2c31;
  --text: #eceef1;
  --text-dim: #9a9ea6;
  --accent: #c7f13a;
  --accent-dim: #8fb52a;
  --danger: #ff6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  color: var(--accent);
  font-size: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.brand p {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.budget {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
}

.budget .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.budget.low .dot { background: var(--danger); }

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

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

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

.panel h2 {
  font-size: 14px;
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 600;
}

.field-group { margin-bottom: 22px; }
.field-group:last-of-type { margin-bottom: 20px; }

.hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.optional {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 6px;
}

.photo-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.photo-slot {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  background: var(--panel-2);
  overflow: hidden;
  color: var(--text-dim);
  font-size: 12px;
  transition: border-color 0.15s ease;
}

.photo-slot:hover { border-color: var(--accent-dim); }

.photo-slot .plus { font-size: 20px; line-height: 1; }

.photo-slot input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-slot img.thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-slot .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.photo-slot.filled .remove-btn { display: flex; }
.photo-slot.filled .plus,
.photo-slot.filled .slot-label { display: none; }

.text-input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: vertical;
}

.text-input:focus { outline: 1px solid var(--accent-dim); }

.small-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.age-readout {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.slider {
  width: 100%;
  accent-color: var(--accent);
  margin: 10px 0 12px;
}

.presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.presets button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
}

.presets button:hover,
.presets button.active {
  border-color: var(--accent);
  color: var(--text);
}

.generate-btn {
  width: 100%;
  background: var(--accent);
  color: #10130a;
  border: none;
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

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

.cost-badge {
  background: rgba(0,0,0,0.15);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.error-text {
  color: var(--danger);
  font-size: 12.5px;
  margin: 10px 0 0;
  min-height: 0;
}

.download-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

.download-btn:hover {
  border-color: var(--accent);
}

.preview-frame {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-placeholder {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.preview-icon { font-size: 28px; display: block; margin-bottom: 8px; }

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.watermark-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  pointer-events: none;
  transform: rotate(-30deg) scale(1.5);
}

.watermark-overlay span {
  color: rgba(255, 255, 255, 0.4);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: 1px;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.preview-loading {
  position: absolute;
  inset: 0;
  background: rgba(14,15,18,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.hidden { display: none !important; }

.gallery-section {
  margin-top: 24px;
}

.gallery-section h2 {
  font-size: 15px;
  margin: 0 0 12px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.gallery-empty {
  color: var(--text-dim);
  font-size: 13px;
  grid-column: 1 / -1;
}

.gallery-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 3 / 4;
  background: var(--panel-2);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-item .tag {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0,0,0,0.65);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.gallery-item .gallery-download {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  text-decoration: none;
}

.gallery-item .gallery-download:hover {
  background: rgba(0,0,0,0.85);
  color: var(--accent);
}
