/* ==============================
   ZUNOX — Global Design System
   ============================== */

:root {
  --bg-dark: #0a0a0f;
  --bg-card: rgba(18, 18, 28, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(139, 92, 246, 0.5);

  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --accent-glow: rgba(139, 92, 246, 0.3);
  --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);

  --text-primary: #f1f0f5;
  --text-secondary: #9b98b0;
  --text-muted: #5a5778;

  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;

  --sidebar-w: 220px;
  --player-h: 80px;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.6);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
}

/* ==============================
   AMBIENT BACKGROUND
   ============================== */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: float 8s ease-in-out infinite;
}

.orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #8b5cf6, transparent);
  top: -100px; left: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #ec4899, transparent);
  bottom: 20%; right: -80px;
  animation-delay: 3s;
}

.orb-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #06b6d4, transparent);
  bottom: -80px; left: 40%;
  animation-delay: 6s;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

/* ==============================
   LAYOUT
   ============================== */

.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  transition: transform 0.3s ease;
}

.sidebar-header {
  margin-bottom: 32px;
  padding-left: 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.8));
}

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

.logo-tagline {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  padding-left: 32px;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s ease;
  text-align: left;
  position: relative;
  width: 100%;
}

.nav-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent);
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.nav-icon { font-size: 16px; }

.badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}

.api-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 4px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--error);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 8px var(--success); }

.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  z-index: 99;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
}

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 32px;
  padding-bottom: calc(var(--player-h) + 32px);
  position: relative;
  z-index: 1;
}

/* ==============================
   PAGES
   ============================== */

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

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

.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ==============================
   GLASS CARD
   ============================== */

.glass-card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 24px;
}

/* ==============================
   GENERATE PAGE LAYOUT
   ============================== */

.generate-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

/* ==============================
   FORM COMPONENTS
   ============================== */

.form-section {
  margin-bottom: 20px;
}

.section-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.optional-badge {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  vertical-align: middle;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}

.mono-text { font-family: 'JetBrains Mono', 'Courier New', monospace; font-size: 13px; }

.form-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239b98b0' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 36px;
}

.form-select option { background: #1a1a2e; }

.char-count {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==============================
   TOGGLE GROUPS
   ============================== */

.toggle-group {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.toggle-btn {
  padding: 7px 18px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* Type buttons (Instrumental / Vocal) */
.type-toggle {
  display: flex;
  gap: 10px;
}

.type-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s;
}

.type-btn:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.type-btn.active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.15);
}

.type-icon { font-size: 22px; }

/* Gender Toggle */
.gender-toggle {
  display: flex;
  gap: 10px;
}

.gender-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s;
}

.gender-btn.active {
  border-color: var(--accent-2);
  background: rgba(236, 72, 153, 0.12);
  color: var(--accent-2);
}

/* ==============================
   STYLE TAGS
   ============================== */

.style-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.style-tag {
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.style-tag:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ==============================
   MODEL GRID
   ============================== */

.model-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.model-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  text-align: center;
}

.model-btn:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--bg-glass-hover);
}

.model-btn.active {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.12);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.model-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-gradient);
  color: white;
  font-size: 8px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.model-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 6px;
}

.model-desc {
  font-size: 10px;
  color: var(--text-muted);
}

/* ==============================
   ADVANCED SETTINGS
   ============================== */

.advanced-section {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.advanced-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s;
}

.advanced-toggle:hover { background: var(--bg-glass-hover); color: var(--text-primary); }

.arrow { transition: transform 0.2s; font-size: 11px; }
.arrow.open { transform: rotate(180deg); }

.advanced-content { padding: 14px; background: rgba(0,0,0,0.2); }

.slider-group { margin-bottom: 16px; }
.slider-group:last-child { margin-bottom: 0; }

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  margin-top: 8px;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* ==============================
   GENERATE ACTIONS & LOOP
   ============================== */
.generate-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.loop-control {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  height: 48px;
}

.loop-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  white-space: nowrap;
}

.loop-input {
  width: 50px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  outline: none;
  text-align: center;
}

.loop-input::-webkit-inner-spin-button {
  opacity: 1;
}

/* ==============================
   GENERATE BUTTON
   ============================== */

.generate-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  margin-top: 4px;
}

.generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
}

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

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

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

/* Minimalist buttons for tracks */
.btn-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-mini:hover {
  background: var(--bg-glass-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-mini.btn-play {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.2);
  color: var(--accent);
}

.btn-mini.btn-play:hover {
  background: var(--accent);
  color: white;
}

/* ==============================
   GENERATION STATUS
   ============================== */

.generation-status {
  margin-bottom: 20px;
}

.status-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(139, 92, 246, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.status-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.status-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}

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

@keyframes pulse-progress {
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}

.status-stages {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
  transition: color 0.3s;
}

.stage.active { color: var(--accent); }
.stage.done { color: var(--success); }

/* ==============================
   RECENT / LIBRARY TRACKS
   ============================== */

.section-heading {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

.tracks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tracks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.track-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.3s ease;
  cursor: default;
}

.track-card:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-active);
  transform: translateY(-2px);
}

.track-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.track-header-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 4px;
  width: 100%;
}

.track-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.track-time {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

.track-cover {
  width: 48px; height: 48px;
  border-radius: 8px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
}

.track-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.badge-instrumental {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border-color: rgba(139, 92, 246, 0.2);
}

.badge-vocal {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
  border-color: rgba(236, 72, 153, 0.2);
}

.badge-model {
  background: rgba(56, 189, 248, 0.1);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.15);
}

.badge-pending {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.2);
}

.badge-complete {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.2);
}

.badge-error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
}

.track-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.track-badge-dim {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.track-style-text {
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-card-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.track-style-text {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.track-action-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.track-action-btn:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.track-action-btn.play-btn:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

/* Song list within track card */
.song-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  padding-top: 12px;
}

.song-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.03);
  transition: all 0.2s;
}

.song-item:hover {
  background: rgba(139, 92, 246, 0.05);
  border-color: rgba(139, 92, 246, 0.1);
}

.song-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.song-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.song-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-duration {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.saved-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.song-actions {
  display: flex;
  gap: 6px;
}

/* ==============================
   RECENT PRESETS
   ============================== */
.presets-section {
  margin-bottom: 24px;
}

.section-heading-with-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading-with-toggle .section-heading {
  margin-bottom: 0;
}

.toggle-visibility-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  padding: 0;
}

.toggle-visibility-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.toggle-visibility-btn:active {
  transform: scale(0.95);
}

.presets-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: all 0.2s;
}

.preset-item:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-active);
}

.preset-info {
  flex: 1;
  min-width: 0;
}

.preset-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.preset-meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.preset-load-btn {
  padding: 4px 10px;
  font-size: 11px;
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.preset-load-btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
}

/* ==============================
   EMPTY STATE
   ============================== */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 36px; margin-bottom: 12px; }

/* ==============================
   LIBRARY PAGE
   ============================== */

.library-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
}

.search-input { max-width: 360px; }

/* ==============================
   SETTINGS PAGE
   ============================== */

.settings-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.settings-card {
  margin-bottom: 24px;
}

.settings-card-header {
  margin-bottom: 20px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.link {
  color: var(--accent);
  text-decoration: none;
}

.link:hover { text-decoration: underline; }

.settings-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.credits-results {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.credits-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}

.credits-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.credit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  gap: 12px;
}

.credit-key {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credit-amount {
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}

.credit-amount.error { color: var(--error); }

.credit-amount.low {
  color: var(--error);
  font-weight: 600;
}

.removed-label {
  display: inline-block;
  margin-left: 6px;
  background: rgba(239, 68, 68, 0.2);
  color: var(--error);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
}

.credit-removed {
  opacity: 0.5;
  text-decoration: line-through;
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.04);
}

.credit-removed .credit-key {
  color: var(--text-muted);
}

/* ==============================
   STORED KEYS SECTION
   ============================== */

.stored-keys-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.stored-keys-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stored-key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.stored-key-item:hover {
  background: rgba(139, 92, 246, 0.05);
  border-color: rgba(139, 92, 246, 0.1);
}

.stored-key-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stored-key-index {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 24px;
  text-align: center;
}

.stored-key-value {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

.stored-key-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stored-key-credits {
  font-size: 13px;
  font-weight: 700;
  color: var(--success);
}

.stored-key-credits.credits-low {
  color: var(--error);
}

.stored-key-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  transition: all 0.2s;
}

.stored-key-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  color: var(--error);
}

/* ==============================
   ABOUT
   ============================== */

.about-content p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.6;
}

.feature-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.feature-item {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-info {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-info-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.api-info-label { color: var(--text-muted); }

.api-info-item code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 5px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--accent);
}

/* ==============================
   FLOATING AUDIO PLAYER
   ============================== */

.audio-player {
  position: fixed;
  bottom: 0; left: var(--sidebar-w); right: 0;
  height: var(--player-h);
  background: rgba(12, 12, 20, 0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 200;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.player-cover {
  width: 48px; height: 48px;
  border-radius: 8px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
}

.player-cover img { width: 100%; height: 100%; object-fit: cover; }

.player-info {
  min-width: 140px;
  max-width: 200px;
  overflow: hidden;
}

.player-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-style {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.player-btn {
  width: 36px; height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
}

.player-btn:hover { background: rgba(255, 255, 255, 0.1); }

.play-pause-btn {
  width: 44px; height: 44px;
  background: var(--accent-gradient);
  box-shadow: 0 4px 16px var(--accent-glow);
  font-size: 16px;
}

.play-pause-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.player-progress-area {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.player-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 32px;
}

.player-progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.player-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
  transition: width 0.1s linear;
}

.player-progress-bar:hover .player-progress-fill {
  filter: brightness(1.2);
}

.player-volume {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 14px;
}

.player-close {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.player-close:hover { color: var(--text-primary); }

/* ==============================
   TOAST NOTIFICATIONS
   ============================== */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 250px;
  max-width: 380px;
  backdrop-filter: blur(16px);
  animation: slideIn 0.3s ease;
  border: 1px solid transparent;
}

.toast-success {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.toast-info {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
  color: #a78bfa;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* ==============================
   RESPONSIVE
   ============================== */

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-header { display: flex; }

  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 70px;
    padding-bottom: calc(var(--player-h) + 16px);
  }

  .audio-player { left: 0; }

  .model-grid { grid-template-columns: repeat(2, 1fr); }

  .player-volume { display: none; }
  .player-info { display: none; }

  .library-toolbar { flex-direction: column; }
  .search-input { max-width: 100%; }
}

/* ==============================
   SCROLLBAR
   ============================== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ==============================
   SELECTION
   ============================== */

::selection { background: rgba(139, 92, 246, 0.3); }
