:root {
  --bg-dark: #0a0c10;
  --bg-card: rgba(22, 27, 34, 0.75);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.35);
  --accent: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.3);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --border-color: rgba(255, 255, 255, 0.12);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-family: 'Outfit', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 15% 15%, rgba(139, 92, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 85% 85%, rgba(6, 182, 212, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(15, 20, 28, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand h1 span {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.model-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 12px;
  font-weight: 500;
}

/* Main Layout */
.main-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.75rem;
  flex: 1;
}

@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
  }
}

/* Panels */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  position: relative;
}

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.panel-header h2 svg {
  color: var(--primary);
}

/* Model Select Cards */
.model-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 640px) {
  .model-cards {
    grid-template-columns: 1fr;
  }
}

.model-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.model-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.model-card.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.25);
}

.model-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.model-desc {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Cover Section */
.cover-section {
  background: rgba(6, 182, 212, 0.05);
  border: 1px dashed rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-group {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: 0.2s;
  font-family: inherit;
}

.tab-btn.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

.file-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
  background: rgba(0, 0, 0, 0.2);
}

.file-dropzone:hover, .file-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(6, 182, 212, 0.1);
}

.file-dropzone svg {
  color: var(--accent);
}

.file-dropzone p {
  font-size: 0.85rem;
  font-weight: 500;
}

.file-dropzone .sub-text {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.preprocess-btn {
  justify-content: center;
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.4);
  color: var(--accent);
  padding: 10px;
}

.preprocess-btn:hover {
  background: rgba(6, 182, 212, 0.3);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.3);
}

.preprocess-result {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #34d399;
}

.result-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-muted);
  word-break: break-all;
}

.code-badge {
  background: rgba(0, 0, 0, 0.4);
  color: #a7f3d0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-with-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-dim);
}

textarea, input[type="text"], input[type="password"], select {
  background: rgba(10, 14, 20, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

/* Preset Tags */
.preset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-tag {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.preset-tag:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.preset-tag.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(6, 182, 212, 0.25));
  border-color: var(--primary);
  color: #fff;
  font-weight: 500;
}

/* Mode Switches */
.mode-switches {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch-label input {
  display: none;
}

.slider {
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  position: relative;
  transition: 0.3s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider {
  background: var(--primary);
}

input:checked + .slider::before {
  transform: translateX(16px);
}

.switch-text {
  font-size: 0.85rem;
  color: var(--text-main);
}

/* Structure Tags Toolbar */
.structure-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}

.toolbar-title {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.btn-tag {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: 0.15s;
}

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

/* Advanced Settings Collapsible */
.advanced-settings {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
}

.advanced-settings summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}

.advanced-settings summary::-webkit-details-marker {
  display: none;
}

.advanced-settings[open] summary .chevron {
  transform: rotate(180deg);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 20px var(--primary-glow);
  transition: all 0.25s ease;
  font-family: inherit;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(139, 92, 246, 0.5);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
  font-family: inherit;
  text-decoration: none;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Player Card */
.player-card {
  background: rgba(10, 14, 20, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.canvas-container {
  width: 100%;
  height: 140px;
  background: #000;
  border-radius: var(--radius-md);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
}

.empty-player-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
  text-align: center;
  padding: 1rem;
}

.empty-player-state p {
  font-weight: 500;
  color: var(--text-muted);
}

.empty-player-state .sub-text {
  font-size: 0.75rem;
}

.now-playing-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.track-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.track-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Custom Controls */
.custom-audio-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.time-display {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
  min-width: 40px;
}

#seekSlider {
  flex: 1;
  accent-color: var(--primary);
  cursor: pointer;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--primary-glow);
  transition: 0.2s;
}

.btn-circle:hover {
  transform: scale(1.05);
  background: var(--primary-hover);
}

/* Lyrics Display Showcase Card */
.lyrics-display-card {
  background: rgba(10, 14, 20, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lyrics-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.lyrics-card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.lyrics-display-box {
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.7;
  color: #e5e7eb;
  padding-right: 6px;
  white-space: pre-wrap;
}

.lyrics-placeholder {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-style: italic;
  text-align: center;
  padding: 1.5rem 0;
}

.tag-highlight {
  display: inline-block;
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.35);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin: 4px 0 2px 0;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 20;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(139, 92, 246, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

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

.loading-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.loading-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* History Section */
.history-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.btn-icon:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon.danger:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: 0.2s;
}

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

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

.history-info h4 {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.history-info p {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.history-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-delete-item {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.btn-delete-item:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
}

.history-empty {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 1.5rem;
}

/* Modal & API Key Guide Box */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: #121721;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.apikey-guide-box {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.apikey-guide-box h4 {
  font-size: 0.85rem;
  color: #c4b5fd;
  font-weight: 600;
}

.apikey-guide-box ol {
  padding-left: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.link-highlight {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  transition: 0.2s;
}

.link-highlight:hover {
  color: #67e8f9;
}

.hidden {
  display: none !important;
}
