:root {
  --bg-dark: #0b0f19;
  --bg-card: rgba(20, 26, 42, 0.7);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-card-hover: rgba(28, 36, 58, 0.85);
  
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --primary-hover: #4f46e5;
  
  --accent: #ec4899;
  --accent-glow: rgba(236, 72, 153, 0.4);
  
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.3);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --danger: #ef4444;
  --success: #10b981;

  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 10% 20%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(236, 72, 153, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(6, 182, 212, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--bg-card-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
}

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

.logo h1 span {
  background: linear-gradient(135deg, #a5b4fc, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.save-status {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* Buttons */
.btn {
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--bg-card-border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #db2777);
  color: white;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-outline-danger {
  background: transparent;
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
}

.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
}

/* Main Layout */
.app-main {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 1.5rem;
  flex: 1;
}

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

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--bg-card-border);
  padding-bottom: 0.75rem;
}

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Audio Setup Section */
.upload-area {
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  background: rgba(99, 102, 241, 0.03);
  transition: all 0.2s ease;
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.upload-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.upload-text strong {
  color: var(--text-main);
}

.browse-link {
  color: var(--primary);
  text-decoration: underline;
}

.file-types {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.file-name-display {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(6, 182, 212, 0.2);
  word-break: break-all;
}

/* Waveform Canvas */
.waveform-container {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  height: 80px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--bg-card-border);
}

#waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.playhead {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  pointer-events: none;
  transition: left 0.1s linear;
}

/* Audio Player Controls */
.audio-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.75rem 1rem;
  border-radius: 12px;
}

.time-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
}

.control-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--bg-card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

.btn-play {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  box-shadow: 0 4px 14px var(--primary-glow);
}

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

.speed-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.speed-control select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  font-family: var(--font-main);
  outline: none;
}

/* Metadata Grid */
.metadata-fields h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.input-group label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-group input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: var(--font-main);
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--primary);
}

/* Tabs */
.tab-navigation {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: var(--text-main);
  background: rgba(99, 102, 241, 0.15);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.tab-content.active {
  display: flex;
}

/* Tab 1 Textarea */
.input-instructions {
  font-size: 0.85rem;
  color: var(--text-muted);
}

#lyrics-raw-input {
  width: 100%;
  flex: 1;
  min-height: 340px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--bg-card-border);
  border-radius: 12px;
  padding: 1rem;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

#lyrics-raw-input:focus {
  border-color: var(--primary);
}

.tab-actions {
  display: flex;
  justify-content: flex-end;
}

/* Tab 2 Sync List */
.sync-banner {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

.kbd {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #fff;
}

.lyrics-list-container {
  flex: 1;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.4rem;
}

/* Custom Scrollbar */
.lyrics-list-container::-webkit-scrollbar, .word-table-container::-webkit-scrollbar {
  width: 6px;
}
.lyrics-list-container::-webkit-scrollbar-track, .word-table-container::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}
.lyrics-list-container::-webkit-scrollbar-thumb, .word-table-container::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}

.lyric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--bg-card-border);
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

.lyric-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.lyric-row.active-row {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

.lyric-row.synced-row {
  border-color: rgba(16, 185, 129, 0.4);
}

.lyric-row-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  min-width: 24px;
}

.lyric-row-text {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}

.lyric-row-timestamp {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  min-width: 90px;
  text-align: center;
}

.lyric-row-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-mini {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-mini:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-mini-tap {
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 600;
}

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

/* Tab 3 Word-by-Word Studio */
.word-sync-banner {
  background: rgba(236, 72, 153, 0.1);
  border-color: rgba(236, 72, 153, 0.3);
}

.word-studio-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--bg-card-border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.word-studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.active-line-badge {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.active-line-text-display {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
}

.word-studio-nav {
  display: flex;
  gap: 0.4rem;
}

.word-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  min-height: 70px;
  align-items: center;
}

.word-chip {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--bg-card-border);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.word-chip:hover {
  background: rgba(255, 255, 255, 0.15);
}

.word-chip.w-active {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  border-color: var(--accent);
  box-shadow: 0 0 15px var(--accent-glow);
  color: #fff;
  font-weight: 700;
  transform: scale(1.05);
}

.word-chip.w-synced {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.15);
}

.word-chip-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--cyan);
  opacity: 0.9;
}

/* Word Timestamps Table */
.word-table-container {
  flex: 1;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--bg-card-border);
  border-radius: 10px;
}

.word-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.word-table th {
  background: rgba(0, 0, 0, 0.5);
  padding: 0.5rem 0.75rem;
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.word-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.word-table tr:hover td {
  background: rgba(255, 255, 255, 0.04);
}

/* Tab 4 Karaoke Preview */
.karaoke-stage {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--bg-card-border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  min-height: 380px;
  position: relative;
}

.karaoke-mode-bar {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(0,0,0,0.4);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--bg-card-border);
}

.karaoke-display {
  text-align: center;
  max-width: 650px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

.placeholder-text {
  color: var(--text-dim);
  font-style: italic;
}

.k-line {
  font-size: 1.3rem;
  color: var(--text-dim);
  transition: all 0.3s ease;
  opacity: 0.5;
}

.k-line.k-past {
  font-size: 1.1rem;
  color: var(--text-muted);
  opacity: 0.7;
}

.k-line.k-active {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  opacity: 1;
  text-shadow: 0 0 20px var(--accent-glow), 0 0 40px var(--primary-glow);
  transform: scale(1.02);
}

/* Word-by-Word glowing karaoke span styling */
.k-word {
  display: inline-block;
  margin: 0 0.18em;
  color: var(--text-muted);
  opacity: 0.5;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.k-word.kw-passed {
  color: #e0e7ff;
  opacity: 0.9;
}

.k-word.kw-active {
  color: #fff;
  opacity: 1;
  font-weight: 900;
  text-shadow: 0 0 15px #f472b6, 0 0 30px #a5b4fc, 0 0 50px #06b6d4;
  transform: scale(1.15) translateY(-3px);
  background: linear-gradient(135deg, #ffffff, #f472b6, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden, .hidden {
  display: none !important;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 16px;
  width: 580px;
  max-width: 90%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--bg-card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

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

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.export-format-selector {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
  background: rgba(0,0,0,0.3);
  padding: 0.75rem;
  border-radius: 8px;
}

#lrc-output-text {
  width: 100%;
  height: 230px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--bg-card-border);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  resize: none;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
