* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --secondary: #64748b;
  --background: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --error: #ef4444;
  --success: #22c55e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

main {
  flex: 1;
}

section {
  margin-bottom: 2rem;
}

.hidden {
  display: none !important;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text);
}

textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--surface-light);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
}

textarea::placeholder {
  color: var(--text-muted);
}

.duration-selector {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

.duration-selector label {
  margin-bottom: 0;
  white-space: nowrap;
}

select {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--surface-light);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--primary);
}

.primary-btn {
  width: 100%;
  padding: 1rem 2rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

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

.primary-btn:disabled {
  background: var(--surface-light);
  cursor: not-allowed;
}

.secondary-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--surface-light);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.secondary-btn:hover {
  border-color: var(--primary);
  background: var(--surface);
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.prompt-box {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: 12px;
  border: 2px solid var(--surface-light);
  margin-bottom: 1rem;
  white-space: pre-wrap;
  line-height: 1.7;
}

.prompt-box.editable {
  min-height: 100px;
  outline: none;
}

.prompt-box.editable:focus {
  border-color: var(--primary);
}

.prompt-actions {
  display: flex;
  gap: 1rem;
}

.prompt-actions .secondary-btn {
  flex: 0 0 auto;
}

.prompt-actions .primary-btn {
  flex: 1;
}

.progress-container {
  text-align: center;
  padding: 3rem 1rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1.5rem;
  animation: spin 1s linear infinite;
}

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

#progress-text {
  color: var(--text-muted);
}

.result-container {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}

audio {
  width: 100%;
  margin-bottom: 1rem;
  border-radius: 8px;
}

.download-btn {
  display: block;
  text-align: center;
  text-decoration: none;
}

.error-box {
  background: rgba(239, 68, 68, 0.1);
  border: 2px solid var(--error);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
}

.error-box h3 {
  color: var(--error);
  margin-bottom: 0.5rem;
}

.error-box p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

footer {
  text-align: center;
  padding-top: 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

@media (max-width: 480px) {
  .container {
    padding: 1.5rem 1rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .prompt-actions {
    flex-direction: column;
  }
}