:root {
  --bg: #0a0a0c;
  --surface: #131316;
  --surface-2: #1c1c20;
  --border: #2a2a2f;
  --text: #f5f5f7;
  --text-dim: #9a9aa2;
  --accent: #f5f5f7;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hero {
  padding: 96px 24px 48px;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
}

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

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.field {
  margin-bottom: 32px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.field .optional {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 0.85rem;
}

#name {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
}

#name:focus { outline: 2px solid var(--text); outline-offset: 1px; }

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.opt {
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.opt:hover { border-color: #4a4a52; }

.opt.selected {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.swatches { gap: 12px; }

.opt.swatch {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid var(--border);
}

.opt.swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text);
}

.generate-btn {
  width: 100%;
  padding: 18px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}

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

.form-error {
  color: #ff6b6b;
  text-align: center;
  margin-top: 12px;
}

.result { margin-top: 48px; }

.result-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(20px);
}

.result-image-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
}

#result-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-dim);
}

.loading[hidden] {
  display: none;
}

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

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

.result-info { padding: 28px; }

.result-info h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.result-info p {
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0 0 12px;
}

.result-info .caption {
  color: var(--text);
  background: var(--surface-2);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.result-actions button,
.result-actions a {
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s;
}

.result-actions button:hover,
.result-actions a:hover { border-color: #4a4a52; }

#start-over {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

.script-block {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.script-block label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.script-block textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

.script-block textarea:focus { outline: 2px solid var(--text); outline-offset: 1px; }

.script-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.script-actions button {
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.script-actions button:disabled { opacity: 0.5; cursor: not-allowed; }

.voice-status {
  color: var(--text-dim);
  font-size: 0.85rem;
}

#voice-player,
#talk-video {
  width: 100%;
  margin-top: 16px;
  border-radius: 10px;
}

.script-actions button.secondary {
  background: var(--surface);
  color: var(--text);
}

.download-audio {
  display: inline-block;
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-decoration: underline;
}

.download-audio[hidden] {
  display: none;
}
