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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 40px;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
}

.card {
  background: white;
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: #667eea;
}

/* Upload Area */
.upload-area {
  border: 3px dashed #667eea;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #f8f9ff;
}

.upload-area:hover {
  border-color: #764ba2;
  background: #f0f2ff;
}

.upload-area.small {
  padding: 20px;
}

.upload-area.dragover {
  border-color: #764ba2;
  background: #e8ebff;
}

.upload-content svg {
  color: #667eea;
  margin-bottom: 12px;
}

.upload-content p {
  margin: 8px 0;
  color: #666;
}

.upload-hint {
  font-size: 0.9rem;
  color: #999;
}

/* Preview */
.preview-container {
  margin-top: 20px;
}

.preview-wrapper {
  position: relative;
  display: inline-block;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.preview-wrapper img,
.preview-wrapper video {
  max-width: 100%;
  max-height: 400px;
  display: block;
}

.remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 0, 0, 0.8);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.remove-btn:hover {
  background: rgba(255, 0, 0, 1);
}

/* Input Tabs */
.input-tabs {
  margin-top: 20px;
}

.tab-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #eee;
}

.tab-button {
  padding: 12px 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  color: #666;
  border-bottom: 3px solid transparent;
  transition: all 0.3s;
}

.tab-button:hover {
  color: #667eea;
}

.tab-button.active {
  color: #667eea;
  border-bottom-color: #667eea;
  font-weight: 600;
}

.tab-panel {
  display: none;
  padding: 20px 0;
}

.tab-panel.active {
  display: block;
}

/* Recording Instructions */
.recording-instructions {
  margin-bottom: 24px;
  padding: 20px;
  background: #f8f9ff;
  border-radius: 12px;
  border: 2px solid #e0e0e0;
}

.instruction-text {
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  font-size: 1rem;
}

.reference-sentence {
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 2px solid #667eea;
}

.reference-sentence p {
  margin: 0;
  font-size: 1.1rem;
  color: #333;
  line-height: 1.6;
  font-style: italic;
  text-align: center;
}

.info-text {
  font-size: 0.9rem;
  color: #666;
  font-style: italic;
  margin-top: 12px;
  padding: 12px;
  background: #f8f9ff;
  border-radius: 8px;
}

.info-box {
  padding: 16px;
  background: #e8f5e9;
  border: 2px solid #4caf50;
  border-radius: 8px;
  margin-bottom: 20px;
}

.info-box p {
  margin: 0;
  color: #2e7d32;
  font-size: 0.95rem;
}

/* Recording Controls */
.recording-controls {
  text-align: center;
}

.record-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto;
  transition: transform 0.2s, box-shadow 0.2s;
}

.record-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.record-btn:active {
  transform: translateY(0);
}

.record-btn.recording {
  background: #ff4444;
}

.record-icon {
  font-size: 1.5rem;
}

.recording-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  color: #ff4444;
  font-weight: 600;
}

.pulse {
  width: 12px;
  height: 12px;
  background: #ff4444;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

/* Audio Preview */
.audio-preview-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 2px solid #e0e0e0;
}

.preview-btn {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.preview-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.preview-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.preview-audio-container {
  margin-top: 20px;
  padding: 20px;
  background: #f8f9ff;
  border-radius: 12px;
  border: 2px solid #28a745;
}

.preview-label {
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
}

.preview-audio-container audio {
  width: 100%;
  margin-bottom: 12px;
}

.preview-note {
  font-size: 0.9rem;
  color: #666;
  font-style: italic;
  margin: 0;
  padding: 12px;
  background: white;
  border-radius: 8px;
}

/* Text Input */
.text-input-group {
  margin-bottom: 20px;
}

.text-input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}

.text-input-group textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.3s;
}

.text-input-group textarea:focus {
  outline: none;
  border-color: #667eea;
}

/* Quality Selector */
.quality-selector {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.quality-selector label {
  font-weight: 600;
  color: #333;
  font-size: 1rem;
}

.quality-select {
  flex: 1;
  max-width: 200px;
  padding: 10px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  cursor: pointer;
  transition: border-color 0.3s;
}

.quality-select:focus {
  outline: none;
  border-color: #667eea;
}

/* Generate Button */
.generate-btn {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 18px 32px;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
}

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

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Progress */
.progress-container {
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  width: 0%;
  transition: width 0.3s;
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.progress-text {
  text-align: center;
  color: #666;
  font-size: 0.9rem;
}

/* Result */
.result-container {
  text-align: center;
}

.result-container video {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  margin-bottom: 20px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.download-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s;
}

.download-btn:hover {
  background: #218838;
}

/* Saved Avatars */
.saved-avatars-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.saved-avatar-item {
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 12px;
  background: #f8f9ff;
  transition: all 0.3s;
}

.saved-avatar-item:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.saved-avatar-preview {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.saved-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.saved-avatar-info {
  margin-bottom: 12px;
}

.saved-avatar-date {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 4px;
}

.saved-avatar-text {
  font-size: 0.9rem;
  color: #333;
  margin: 0;
}

.saved-avatar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.saved-avatar-actions button {
  flex: 1;
  min-width: 60px;
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-load {
  background: #667eea;
  color: white;
}

.btn-load:hover {
  background: #5568d3;
}

.btn-view {
  background: #28a745;
  color: white;
}

.btn-view:hover {
  background: #218838;
}

.btn-delete {
  background: #dc3545;
  color: white;
}

.btn-delete:hover {
  background: #c82333;
}

.no-saved {
  text-align: center;
  color: #999;
  padding: 40px 20px;
  font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .card {
    padding: 20px;
  }

  .option-tabs {
    flex-direction: column;
  }

  .tab-btn {
    text-align: left;
  }

  .saved-avatars-container {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
}

