/* ==================== CSS Variables & Reset ==================== */
:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #1a1a30;
  --border: #2a2a4a;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-light: rgba(99, 102, 241, 0.15);
  --green: #10b981;
  --green-light: rgba(16, 185, 129, 0.15);
  --orange: #f59e0b;
  --orange-light: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-light: rgba(239, 68, 68, 0.15);
  --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --gradient-2: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  --gradient-3: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ==================== Header ==================== */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: 10px;
}

.nav-link {
  padding: 8px 20px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  border: none;
  background: transparent;
  cursor: pointer;
}

.nav-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.nav-link.active {
  color: white;
  background: var(--gradient-1);
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

/* ==================== Main ==================== */
.main { padding: 40px 0 80px; }

.tool-section {
  display: none;
  animation: fadeSlideIn 0.4s ease;
}

.tool-section.active { display: block; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.tool-header {
  text-align: center;
  margin-bottom: 32px;
}

.tool-header h2 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tool-header p {
  color: var(--text-secondary);
  font-size: 16px;
}

.tool-body {
  display: grid;
  gap: 24px;
}

/* ==================== Form Card ==================== */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}

.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group textarea { min-height: 100px; }

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

.form-group.half { flex: 1; }

/* ==================== Tags / Options ==================== */
.genre-tags, .style-tags, .size-options, .duration-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genre-tag, .style-tag, .size-option, .duration-option {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.genre-tag:hover, .style-tag:hover, .size-option:hover, .duration-option:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.genre-tag.active, .style-tag.active, .size-option.active, .duration-option.active {
  background: var(--gradient-1);
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* ==================== Buttons ==================== */
.form-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--gradient-1);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
  font-family: inherit;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-icon { font-size: 18px; }

.btn-copy, .btn-download {
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-copy:hover, .btn-download:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--accent-light);
}

/* ==================== Result Card ==================== */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  animation: fadeSlideIn 0.5s ease;
}

.result-card.hidden { display: none; }

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.result-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.result-info {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

/* ==================== Novel Result ==================== */
.novel-content {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 24px;
  max-height: 600px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.9;
  white-space: pre-wrap;
  color: var(--text-primary);
}

.novel-content::-webkit-scrollbar { width: 6px; }
.novel-content::-webkit-scrollbar-track { background: transparent; }
.novel-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ==================== Image Result ==================== */
.image-container {
  position: relative;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: var(--radius);
  overflow: hidden;
}

.generated-image {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: var(--radius);
}

.generated-image.hidden { display: none; }

/* ==================== Video Result ==================== */
.video-container {
  position: relative;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: var(--radius);
  overflow: hidden;
}

.generated-video {
  width: 100%;
  max-height: 500px;
  border-radius: var(--radius);
}

.generated-video.hidden { display: none; }

/* ==================== Loading ==================== */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.image-loading, .video-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px;
  color: var(--text-secondary);
}

.image-loading.hidden, .video-loading.hidden { display: none; }

.progress-bar {
  width: 300px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-1);
  border-radius: 2px;
  width: 0%;
  animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
  0% { width: 10%; }
  50% { width: 70%; }
  100% { width: 10%; }
}

/* ==================== Footer ==================== */
.footer {
  text-align: center;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

.footer a {
  color: var(--accent-hover);
  text-decoration: none;
}

.footer-note {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    height: auto;
    padding: 12px 0;
    gap: 12px;
  }

  .nav-links { width: 100%; justify-content: center; }
  .nav-link { padding: 8px 14px; font-size: 13px; }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-card, .result-card { padding: 20px; }

  .tool-header h2 { font-size: 24px; }

  .image-loading, .video-loading { padding: 32px 16px; }
  .progress-bar { width: 200px; }
}

@media (max-width: 480px) {
  .genre-tags, .style-tags { gap: 4px; }
  .genre-tag, .style-tag { padding: 6px 12px; font-size: 12px; }
  .nav-link { padding: 6px 10px; font-size: 12px; }
}
