/**
 * Guitar Study Pro - Redesigned Layout Styles
 * Based on blue prototype with current dark/orange theme
 */

/* === LAYOUT STRUCTURE === */
.main-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
}

/* === WAVEFORM SECTION === */
.waveform-section {
  width: 100%;
}

.waveform-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.waveform-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-md);
  color: var(--accent-primary);
}

.waveform-actions {
  display: flex;
  gap: 0.5rem;
}

.waveform-container {
  position: relative;
  width: 100%;
  height: var(--waveform-height);
  background: var(--bg-secondary);
  border-radius: 0.75rem;
  overflow: hidden;
  touch-action: none;
}

.waveform-canvas {
  width: 100%;
  height: 100%;
}

#waveformCanvas {
  touch-action: none; /* TOUCH-01: hand all touch input to JS; disable browser scroll/zoom on canvas */
}

.waveform-progress {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: rgba(255, 107, 53, 0.15);
  pointer-events: none;
  transition: width 0.1s linear;
}

.waveform-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-secondary);
  pointer-events: none;
  transition: left 0.05s linear;
}

.waveform-loop-region {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(255, 107, 53, 0.2);
  border-left: 2px solid var(--accent-primary);
  border-right: 2px solid var(--accent-primary);
  pointer-events: none;
}

.waveform-time-display {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

/* === TRANSPORT BAR === */
.transport-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-radius: 0.75rem;
  padding: var(--sp-md) var(--sp-lg);
  gap: var(--sp-lg);
}

.transport-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-lg);
  color: var(--accent-primary);
  min-width: 140px;
}

.transport-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.transport-btn {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.transport-btn:hover:not(:disabled) {
  border-color: var(--accent-primary);
  color: var(--fg-primary);
}

.transport-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.transport-btn.play {
  width: 3.5rem;
  height: 3.5rem;
  background: linear-gradient(135deg, var(--accent-primary), #e55a28);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: var(--fs-xl);
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.transport-btn.play:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.5);
}

.transport-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.transport-volume {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
}

.transport-volume input[type="range"] {
  width: 100%;
  height: 4px;
}

/* === CONTROL GRID === */
.control-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 1024px) {
  .control-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

/* === CONTROL CARDS === */
.control-card {
  background: var(--bg-secondary);
  border-radius: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
}

.control-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.control-card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.control-card-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--fg-primary);
}

.control-card-unit {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  margin-left: 0.25rem;
}

/* === SLIDERS === */
.control-slider {
  width: 100%;
  height: 6px;
  margin-bottom: 0.5rem;
}

.control-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  margin-top: 0.25rem;
}

/* === PRESET BUTTONS === */
.preset-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.preset-btn {
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  color: var(--fg-secondary);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  background: var(--border);
  color: var(--fg-primary);
}

.preset-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* === METRONOME BEAT DOTS === */
.beat-dots {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.beat-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--bg-tertiary);
  transition: all 0.15s ease;
}

.beat-dot.active {
  background: var(--accent-primary);
  transform: scale(1.25);
}

.beat-dot.downbeat {
  background: var(--accent-secondary);
  transform: scale(1.25);
}

/* === TOGGLE SWITCH === */
.toggle-switch {
  position: relative;
  width: 3rem;
  height: 1.5rem;
  background: var(--bg-tertiary);
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle-switch.active {
  background: var(--accent-primary);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  width: 1rem;
  height: 1rem;
  background: white;
  border-radius: 50%;
  transition: left 0.2s ease;
}

.toggle-switch.active::after {
  left: 1.5rem;
}

/* === STEM MIXER === */
.stem-mixer-card {
  grid-column: span 1;
}

.stem-channel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.stem-channel:last-child {
  margin-bottom: 0;
}

.stem-channel-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  min-width: 60px;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.stem-channel-slider {
  flex: 1;
  height: 4px;
}

.stem-channel-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  min-width: 32px;
  text-align: right;
}

.stem-status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--fg-muted);
}

.stem-status-dot.ready {
  background: var(--accent-secondary);
}

/* === PITCH CONTROL === */
.pitch-display {
  text-align: center;
  margin-bottom: 1rem;
}

.pitch-value {
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--fg-primary);
}

.pitch-tuning {
  font-size: var(--fs-md);
  color: var(--fg-muted);
  margin-top: 0.25rem;
}

.pitch-dropdown {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  color: var(--fg-primary);
  font-size: var(--fs-md);
  cursor: pointer;
}

.pitch-dropdown:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* === TABS SYSTEM === */
.tabs-container {
  background: var(--bg-secondary);
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  overflow: visible;
}

.tabs-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  border-radius: 0.75rem 0.75rem 0 0;
  overflow: hidden;
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  color: var(--fg-secondary);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--fg-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tab-content {
  padding: 1rem;
  min-height: 200px;
}

.tab-panel {
  display: none;
}

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

/* === REGIONS LIST === */
.regions-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  color: var(--fg-muted);
}

.regions-empty-icon {
  font-size: var(--fs-4xl);
  margin-bottom: 1rem;
  opacity: 0.5;
}

.regions-empty-text {
  font-size: var(--fs-md);
  margin-bottom: 0.5rem;
}

.regions-empty-hint {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

.region-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.region-item:hover {
  background: var(--border);
}

.region-item.active {
  border-left: 3px solid var(--accent-primary);
}

.region-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.region-name {
  font-size: var(--fs-md);
  font-weight: 500;
}

.region-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

.region-actions {
  display: flex;
  gap: 0.5rem;
}

.region-action-btn {
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
}

.region-action-btn:hover {
  background: var(--bg-secondary);
  color: var(--fg-primary);
}

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

/* === SECTION OVERLAYS (WAVEFORM) === */
.section-block {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 2;
  border-left: 2px solid;
  border-right: 2px solid;
}

.section-block.active {
  box-shadow: 0 0 12px 2px var(--section-border-color, #ffffff44);
  z-index: 3;
}

.section-label {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 8px);
  pointer-events: auto;
  cursor: text;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  z-index: 4;
}

.section-label-input {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-secondary);
  color: var(--fg-primary);
  border: 1px solid var(--accent-primary);
  border-radius: 3px;
  padding: 1px 4px;
  outline: none;
  width: auto;
  min-width: 60px;
  max-width: calc(100% - 8px);
  pointer-events: auto;
  z-index: 5;
}

.section-wf-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  pointer-events: auto;
  text-transform: capitalize;
  white-space: nowrap;
  z-index: 4;
}

.section-wf-badge:hover {
  filter: brightness(1.3);
}

.section-wf-dropdown {
  position: fixed;
  z-index: 100;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Section type color variants */
.section-block--intro { background: rgba(99, 102, 241, 0.25); border-color: #6366f1; --section-border-color: #6366f1; }
.section-block--intro .section-label { color: #a5b4fc; }
.section-block--verse { background: rgba(59, 130, 246, 0.25); border-color: #3b82f6; --section-border-color: #3b82f6; }
.section-block--verse .section-label { color: #93c5fd; }
.section-block--pre-chorus { background: rgba(20, 184, 166, 0.25); border-color: #14b8a6; --section-border-color: #14b8a6; }
.section-block--pre-chorus .section-label { color: #5eead4; }
.section-block--chorus { background: rgba(0, 212, 170, 0.25); border-color: #00d4aa; --section-border-color: #00d4aa; }
.section-block--chorus .section-label { color: #6ee7d4; }
.section-block--bridge { background: rgba(168, 85, 247, 0.25); border-color: #a855f7; --section-border-color: #a855f7; }
.section-block--bridge .section-label { color: #d8b4fe; }
.section-block--solo { background: rgba(255, 107, 53, 0.25); border-color: #ff6b35; --section-border-color: #ff6b35; }
.section-block--solo .section-label { color: #ff9f7a; }
.section-block--outro { background: rgba(156, 163, 175, 0.25); border-color: #9ca3af; --section-border-color: #9ca3af; }
.section-block--outro .section-label { color: #d1d5db; }
.section-block--other { background: rgba(251, 191, 36, 0.25); border-color: #fbbf24; --section-border-color: #fbbf24; }
.section-block--other .section-label { color: #fde68a; }

/* Sub-loop hatched overlay */
.sub-loop-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.08) 0px,
    rgba(255, 255, 255, 0.08) 4px,
    transparent 4px,
    transparent 10px
  );
  border-left: 2px solid rgba(255, 255, 255, 0.5);
  border-right: 2px solid rgba(255, 255, 255, 0.5);
  pointer-events: none;
  z-index: 3;
}

/* === SECTION LIST (REGIONS PANEL) === */
.section-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.2s ease;
  border-left: 3px solid var(--border);
}

.section-item:hover {
  background: var(--border);
}

.section-item.active {
  border-left-color: var(--accent-primary);
}

.section-item.flash-error {
  background: rgba(239, 68, 68, 0.3);
  transition: background 0.3s ease;
}

.section-type-badge {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: capitalize;
}

.section-editing .section-name-input {
  display: block;
}

.section-name-input {
  background: var(--bg-primary);
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  color: var(--fg-primary);
  font-size: var(--fs-md);
  font-weight: 400;
  padding: 4px 8px;
  width: 100%;
  outline: none;
}

.section-type-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg-primary);
  font-size: var(--fs-sm);
  padding: 4px 8px;
  outline: none;
}

.section-type-select:focus {
  border-color: var(--accent-primary);
}

.section-type-wrapper {
  position: relative;
}

.section-type-badge.clickable {
  cursor: pointer;
}

.section-type-badge.clickable:hover {
  filter: brightness(1.2);
}

.section-type-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  margin-top: 4px;
}

.section-type-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: var(--fs-sm);
  color: var(--fg-secondary);
  cursor: pointer;
  text-transform: capitalize;
}

.section-type-option:hover {
  background: var(--bg-tertiary);
  color: var(--fg-primary);
}

.section-type-option.selected {
  color: var(--fg-primary);
  font-weight: 600;
}

.section-type-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.section-type-custom-opt {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
}

.section-time-fields {
  display: flex;
  align-items: center;
  gap: 2px;
}

.section-time-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-sm);
  color: var(--fg-secondary);
  min-width: 36px;
  text-align: center;
}

.section-time-sep {
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  margin: 0 4px;
}

.section-nudge-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--fg-muted);
  font-size: var(--fs-xs);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.section-nudge-btn:hover {
  border-color: var(--accent-primary);
  color: var(--fg-primary);
}

.regions-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.auto-play-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  cursor: pointer;
}

.auto-play-label input[type="checkbox"] {
  accent-color: var(--accent-secondary);
}

/* === TABLATURE === */
.tablature-content {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-md);
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
}

.tab-line {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.tab-line:hover {
  background: var(--bg-tertiary);
}

.tab-timestamp {
  font-size: var(--fs-sm);
  color: var(--accent-secondary);
  background: rgba(0, 212, 170, 0.1);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  min-width: 50px;
  text-align: center;
}

.tab-notation {
  flex: 1;
  color: var(--fg-primary);
}

.tab-technique {
  font-size: var(--fs-sm);
  color: var(--accent-primary);
  font-style: italic;
}

/* === SESSION MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  border: 1px solid var(--border);
}

.modal-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-subtitle {
  font-size: var(--fs-md);
  color: var(--fg-secondary);
  margin-bottom: 1.5rem;
}

.session-info {
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.session-song {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.session-date {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
}

.modal-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: var(--fs-md);
}

.modal-btn.primary {
  background: linear-gradient(135deg, var(--accent-primary), #e55a28);
  color: white;
}

.modal-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.modal-btn.secondary {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--fg-secondary);
}

.modal-btn.secondary:hover {
  border-color: var(--accent-secondary);
  color: var(--fg-primary);
}

/* === TAP TEMPO === */
.tap-tempo-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--fg-secondary);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.tap-tempo-btn:hover {
  background: var(--border);
  color: var(--fg-primary);
}

.tap-tempo-btn:active {
  background: var(--accent-primary);
  color: white;
}

/* === UTILITIES === */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-4 {
  margin-top: 1rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

/* === LIBRARY SIDEBAR === */
.library-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  transition: opacity 0.2s ease;
}
.library-overlay.hidden { display: none; }

.library-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100dvh;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 200;
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.library-sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}
@supports not (height: 100dvh) {
  .library-sidebar { height: 100vh; }
}

/* DESK-02: Resizable sidebar divider (desktop only) */
.sidebar-divider {
  display: none; /* hidden on mobile/tablet */
  position: fixed;
  left: var(--sidebar-width); /* updated by JS */
  top: 0;
  width: 5px;
  height: 100dvh;
  background: var(--border);
  cursor: col-resize;
  z-index: 201;
  transition: background 0.15s ease;
}
.sidebar-divider:hover,
.sidebar-divider.dragging {
  background: var(--accent-primary);
}
.library-sidebar.collapsed ~ .sidebar-divider {
  display: none !important;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-lg);
  border-bottom: 1px solid var(--border);
}
.library-header-title {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--accent-primary);
}
.library-close-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 4px;
}
.library-close-btn:hover { color: var(--fg-primary); }

.library-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.library-empty {
  text-align: center;
  color: var(--fg-muted);
  font-size: var(--fs-md);
  padding: 32px 16px;
}

.library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  border-left: 3px solid transparent;
}
.library-item:hover { background: var(--border); }
.library-item.active { border-left-color: var(--accent-primary); }

.library-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.library-item-title {
  font-size: var(--fs-md);
  color: var(--fg-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stems-badge {
  display: inline-block;
  background: rgba(0, 212, 170, 0.15);
  color: var(--accent-secondary);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  width: fit-content;
}

.library-delete {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  font-size: var(--fs-xl);
  flex-shrink: 0;
}
.library-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Stem export button */
.stem-mute-btn, .stem-solo-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--fg-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.stem-mute-btn:hover, .stem-solo-btn:hover {
  color: var(--fg-primary);
  background: var(--bg-secondary);
}
.stem-mute-btn.active {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.stem-solo-btn.active {
  background: var(--accent-secondary);
  color: #000;
  border-color: var(--accent-secondary);
}
.stem-export-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease;
}
.stem-export-btn:hover:not(:disabled) {
  background: var(--bg-secondary);
  color: var(--fg-primary);
}
.stem-export-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === AUTH FORMS === */
.auth-header {
  text-align: center;
  padding: 1.5rem 1rem 1rem;
}
.auth-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.5rem;
  background: linear-gradient(135deg, var(--accent-primary), #e55a28);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-app-name {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--fg-primary);
}
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin: 0 1rem;
}
.auth-tab {
  flex: 1;
  padding: 0.625rem;
  text-align: center;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--fg-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.auth-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}
.auth-tab:hover {
  color: var(--fg-secondary);
}
#authFormArea {
  padding: 1rem;
}
.auth-field {
  margin-bottom: 0.75rem;
}
.auth-field label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--fg-secondary);
  margin-bottom: 0.25rem;
}
.auth-field input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-primary);
  font-size: var(--fs-md);
  outline: none;
  transition: border-color 0.2s;
}
.auth-field input:focus {
  border-color: var(--accent-primary);
}
.auth-field-error {
  font-size: var(--fs-sm);
  color: #ef4444;
  margin-top: 0.25rem;
  display: none;
}
.auth-field-error.visible {
  display: block;
}
.auth-submit-btn {
  width: 100%;
  padding: 0.625rem;
  background: linear-gradient(135deg, var(--accent-primary), #e55a28);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}
.auth-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}
.auth-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.auth-link {
  font-size: var(--fs-sm);
  color: var(--accent-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.auth-link:hover {
  color: var(--fg-primary);
}
.auth-user-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}
.auth-user-name {
  font-size: var(--fs-md);
  color: var(--fg-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.auth-logout-btn {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}
.auth-logout-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* === BANNERS === */
.demo-banner {
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-primary);
  border-radius: 8px;
  padding: 0.625rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-md);
  color: var(--fg-secondary);
}
.verify-banner {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 8px;
  padding: 0.625rem 1rem;
  margin-bottom: 1rem;
  font-size: var(--fs-md);
  color: #eab308;
}
.banner-dismiss {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: var(--fs-xl);
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}
.banner-dismiss:hover {
  color: var(--fg-primary);
}
.migration-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid #ef4444;
  border-bottom-width: 2px;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: var(--fs-sm);
  color: var(--fg-primary);
}
.migration-banner.hidden {
  display: none;
}
.migration-banner-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.migration-retry-btn {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: var(--fs-sm);
  cursor: pointer;
  flex-shrink: 0;
}
.migration-retry-btn:hover {
  opacity: 0.9;
}
.migration-retry-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* === TUTORIAL OVERLAY === */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tutorial-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}
.tutorial-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
}
.tutorial-step-indicator {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  margin-bottom: 1rem;
}
.tutorial-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.tutorial-desc {
  font-size: var(--fs-md);
  color: var(--fg-secondary);
  margin-bottom: 1.5rem;
}
.tutorial-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.tutorial-skip {
  flex: 1;
  padding: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-muted);
  font-size: var(--fs-md);
  cursor: pointer;
}
.tutorial-skip:hover {
  border-color: var(--fg-secondary);
  color: var(--fg-secondary);
}
.tutorial-next {
  flex: 1;
  padding: 0.5rem;
  background: linear-gradient(135deg, var(--accent-primary), #e55a28);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
}

/* === LIBRARY ENHANCEMENTS === */

.library-controls {
  padding: var(--sp-md) var(--sp-lg);
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.library-control-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.library-search {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-primary);
  font-size: var(--fs-md);
  outline: none;
}

.library-search:focus {
  border-color: var(--accent-primary);
}

.library-sort {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-primary);
  font-size: var(--fs-md);
  outline: none;
  min-width: 140px;
}

.library-sort:focus {
  border-color: var(--accent-primary);
}

.library-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.library-chip {
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--fg-secondary);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.library-chip:hover {
  border-color: var(--accent-secondary);
  color: var(--fg-primary);
}

.library-chip.active {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: #000;
  font-weight: 600;
}

.library-stats {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  text-align: center;
}

/* Library Cards */
.library-card {
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: var(--sp-lg);
  margin-bottom: var(--sp-md);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  cursor: pointer;
}

.library-card:hover {
  border-color: var(--accent-secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.library-card.active {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.1), rgba(0, 212, 170, 0.05));
}

.library-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.library-card-title {
  flex: 1;
  min-width: 0;
}

.library-card-name {
  display: block;
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--fg-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-card-artist {
  display: block;
  font-size: var(--fs-md);
  color: var(--fg-secondary);
  font-style: italic;
}

.library-card-load-btn {
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--accent-primary), #e55a28);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.library-card-load-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
}

.library-card-meta {
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.library-card-duration {
  font-size: var(--fs-sm);
  color: var(--accent-secondary);
  background: rgba(0, 212, 170, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
}

.library-card-date {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

.library-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.library-badge {
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.library-badge.tuning {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.library-badge.bpm {
  background: rgba(20, 184, 166, 0.15);
  color: #5eead4;
  border: 1px solid rgba(20, 184, 166, 0.3);
}

.library-badge.sections {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.library-badge.stems {
  background: rgba(0, 212, 170, 0.15);
  color: #6ee7d4;
  border: 1px solid rgba(0, 212, 170, 0.3);
}

.library-badge.tempo {
  background: rgba(255, 107, 53, 0.15);
  color: #ff9f7a;
  border: 1px solid rgba(255, 107, 53, 0.3);
}

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

.library-delete {
  padding: 6px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  color: #ef4444;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Delete Modal */
.delete-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.delete-modal-content {
  background: var(--bg-secondary);
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  border: 1px solid var(--border);
}

.delete-modal-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--fg-primary);
}

.delete-modal-subtitle {
  font-size: var(--fs-md);
  color: var(--fg-secondary);
  margin-bottom: 1.5rem;
}

.delete-modal-actions {
  display: flex;
  gap: 0.75rem;
}

.delete-modal-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: var(--fs-md);
}

.delete-modal-btn.cancel {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--fg-secondary);
}

.delete-modal-btn.cancel:hover {
  border-color: var(--accent-secondary);
  color: var(--fg-primary);
}

.delete-modal-btn.delete {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.delete-modal-btn.delete:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* Upgrade Modal — card-based plan selector (Phase 06-02) */
.upgrade-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.upgrade-modal-overlay.hidden { display: none; }
.upgrade-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: var(--sp-xl);
  max-width: 520px;
  width: 100%;
  text-align: center;
}
.upgrade-modal-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--fg-primary);
  margin: 0 0 8px;
}
.upgrade-modal-subtitle {
  font-size: var(--fs-md);
  color: var(--fg-secondary);
  margin: 0 0 16px;
}
/* Plan cards grid */
.upgrade-plan-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
@media (max-width: 480px) {
  .upgrade-plan-cards { grid-template-columns: 1fr; }
}
.upgrade-plan-card {
  position: relative;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}
.upgrade-plan-card:hover {
  border-color: var(--accent-secondary);
  transform: translateY(-2px);
}
.upgrade-plan-card.selected {
  border: 2px solid var(--accent-primary);
  background: linear-gradient(135deg, rgba(255,107,53,0.08), transparent);
}
.upgrade-plan-badge {
  position: absolute;
  top: -10px;
  right: 8px;
  font-size: var(--fs-sm);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}
.upgrade-plan-badge--recommended {
  background: var(--accent-secondary);
  color: #000;
}
.upgrade-plan-badge--lifetime {
  background: var(--accent-tertiary);
  color: #fff;
}
.upgrade-plan-name {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--fg-primary);
  margin-bottom: 6px;
}
.upgrade-plan-price {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-bottom: 4px;
}
.upgrade-plan-amount {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--accent-primary);
  font-family: 'JetBrains Mono', monospace;
}
.upgrade-plan-period {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--fg-muted);
}
.upgrade-plan-billed {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  margin-bottom: 6px;
}
.upgrade-plan-features {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.upgrade-plan-features li {
  font-size: var(--fs-sm);
  color: var(--fg-secondary);
  padding-left: 14px;
  position: relative;
}
.upgrade-plan-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent-secondary);
  font-size: var(--fs-sm);
}
.upgrade-pix-note {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  margin: 0 0 12px;
}
.upgrade-pix-note.hidden { display: none; }
.upgrade-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.upgrade-modal-actions .modal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.upgrade-modal-dismiss {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 400;
  padding: 4px;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: color 0.2s;
}
.upgrade-modal-dismiss:hover {
  color: var(--fg-secondary);
}
/* Payment toasts */
.payment-toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1001;
  max-width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-secondary);
  border-radius: 8px;
  padding: var(--sp-md) var(--sp-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeInUp 0.3s ease-out;
  font-size: var(--fs-md);
  color: var(--fg-primary);
}
.payment-toast.hidden { display: none; }
.payment-toast--cancel {
  border-color: #ef4444;
}
.payment-toast--cancel .payment-toast-icon {
  color: #ef4444;
}
.payment-toast-icon {
  color: var(--accent-secondary);
  flex-shrink: 0;
  display: flex;
}
.payment-toast-text {
  flex: 1;
}
/* Pro Badge */
.pro-badge {
  display: inline-block;
  background: var(--accent-secondary);
  color: #000;
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 6px;
}
.pro-badge.hidden { display: none; }

.tempo-display-label {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--fg-primary);
  min-width: 3rem;
  text-align: center;
}

/* Processing indicator: brief color pulse on slider thumb when tempo/pitch changes */
@keyframes processing-pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-primary); }
  50% { box-shadow: 0 0 8px 3px var(--accent-primary); }
  100% { box-shadow: 0 0 0 0 var(--accent-primary); }
}

.control-slider.processing-pulse::-webkit-slider-thumb {
  animation: processing-pulse 0.2s ease-out;
}

.control-slider.processing-pulse::-moz-range-thumb {
  animation: processing-pulse 0.2s ease-out;
}

/* ── Tab Import ──────────────────────────────────────────────────────────── */

.import-source-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.import-source-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--fg-secondary);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  min-height: 44px;
}

.import-source-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.import-source-panel {
  display: none;
}

.import-source-panel.active {
  display: block;
}

.tab-drop-zone {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.tab-drop-zone:hover,
.tab-drop-zone.drag-active {
  border-color: var(--accent-primary);
  border-width: 2px;
  background: rgba(255, 107, 53, 0.05);
}

.input-error {
  border-color: #ef4444 !important;
}

/* ── Tab Card Enhancements ───────────────────────────────────────────────── */

.tab-card.orphaned {
  opacity: 0.7;
  border-style: dashed;
}

.tab-card-status {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0 4px;
}

.tab-link-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.tab-link-dot.linked {
  background: var(--accent-secondary);
}

.tab-link-dot.orphaned {
  background: var(--fg-muted);
}

.tab-link-label {
  font-size: var(--fs-sm);
}

.tab-link-label.linked {
  color: var(--accent-secondary);
}

.tab-link-label.orphaned {
  color: var(--fg-muted);
}

.tab-card-edit {
  background: none;
  border: none;
  color: var(--fg-secondary);
  cursor: pointer;
  padding: 4px 8px;
  font-size: var(--fs-md);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-card-edit:hover {
  color: var(--accent-primary);
}

.tab-inline-edit {
  width: 100%;
  padding: var(--sp-md);
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--fg-primary);
  font-size: var(--fs-md);
  line-height: 1.6;
  resize: vertical;
}

/* ── Preview Panel ───────────────────────────────────────────────────────── */

.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.preview-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-type-chip {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--fs-sm);
  font-weight: 600;
  border: 1px solid;
}

.preview-section-name {
  font-size: var(--fs-md);
  color: var(--fg-primary);
}

.preview-section-time {
  font-size: var(--fs-sm);
  color: var(--fg-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.preview-type-select {
  font-size: var(--fs-sm);
}

/* ========================================
   PHASE 7: RESPONSIVE LAYOUT SYSTEM
   Mobile-first: base = mobile (0-767px)
   ======================================== */

/* --- BOTTOM NAV BAR --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--bottom-nav-height, 56px);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 6px 4px;
  transition: color 0.2s ease;
  min-height: 44px;
}

.bottom-nav-tab.active,
.bottom-nav-tab:focus-visible {
  color: var(--accent-primary);
}

.bottom-nav-tab:hover:not(.active) {
  color: var(--fg-secondary);
}

.bottom-nav-icon {
  font-size: var(--fs-xl);
  line-height: 1;
}

.bottom-nav-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
}

/* --- MOBILE BASE (0-767px) --- */

/* Waveform taller on mobile for touch */
@media (max-width: 767px) {
  .waveform-container {
    height: clamp(160px, 30vh, 220px);
  }
  @supports (height: 1dvh) {
    .waveform-container {
      height: clamp(160px, 30dvh, 220px);
    }
  }
}

/* Transport bar sticky on mobile */
@media (max-width: 767px) {
  .transport-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-secondary);
  }
}

/* iOS auto-zoom prevention — TOUCH-03 */
@media (max-width: 767px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Mobile header adjustments */
@media (max-width: 767px) {
  /* Hide library button — Library is a bottom nav tab */
  #libraryToggleBtn {
    display: none;
  }

  /* Hide full API badge — replaced by status dot */
  .api-badge {
    display: none;
  }

  /* Show compact status dot */
  .api-status-dot {
    display: inline-block;
  }

  /* Song name in header — truncated */
  .current-song-name {
    display: block;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--fg-secondary);
  }

  /* Main content needs bottom padding for nav bar */
  #appViewsWrapper {
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0) + 8px);
  }

  /* Mobile library full-screen */
  .library-sidebar {
    width: 100dvw;
    height: 100dvh;
    border-right: none;
  }
  .library-sidebar.collapsed {
    transform: translateX(-100dvw);
  }
}

/* API status dot — hidden on desktop by default */
.api-status-dot {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-muted);
}
.api-status-dot.online {
  background: var(--accent-secondary);
}

/* Song name display — hidden on desktop by default */
.current-song-name {
  display: none;
}

/* --- TOUCH TARGET ENLARGEMENT --- */

/* Use pointer: coarse for device capability, not viewport size */
@media (pointer: coarse) {
  .transport-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  /* Slider thumbs enlarged */
  input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    margin-top: -10px;
  }
  input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }

  /* Mute/Solo buttons */
  .stem-mute-btn,
  .stem-solo-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* --- TABLET (768px+) --- */
@media (min-width: 768px) {
  .waveform-container {
    height: clamp(150px, 25vh, 260px);
  }
  @supports (height: 1dvh) {
    .waveform-container {
      height: clamp(150px, 25dvh, 260px);
    }
  }

  /* Restore song name hidden on tablet+ */
  .current-song-name {
    display: none;
  }
}

/* --- DESKTOP (1024px+) --- */
@media (min-width: 1024px) {
  /* All view panels always visible on desktop */
  .view-panel {
    display: block !important;
  }

  /* DESK-02: Show sidebar divider on desktop */
  .sidebar-divider {
    display: block;
  }

  /* Desktop restores library button */
  #libraryToggleBtn {
    display: flex;
  }

  /* API badge visible on desktop */
  .api-badge {
    display: inline-block;
  }

  /* Desktop: hide bottom nav */
  .bottom-nav {
    display: none !important;
  }

  /* Desktop: main container max-width */
  #appViewsWrapper {
    padding-bottom: 0;
  }
}

/* --- WIDE / 4K (1440px+) --- */
@media (min-width: 1440px) {
  .main-container,
  #appViewsWrapper {
    max-width: 1920px;
  }
}

/* --- BOTTOM NAVIGATION BAR (Plan 02 additions) --- */

/* Active indicator line at top of active tab */
.bottom-nav-tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 2px;
  background: var(--accent-primary);
  border-radius: 0 0 2px 2px;
}

.bottom-nav-tab {
  position: relative;
  font-family: 'Space Grotesk', sans-serif;
}

/* Tablet: hide Pitch/Speed and Metronome tabs (3-tab variant) */
@media (min-width: 768px) and (max-width: 1023px) {
  .bottom-nav-tab[data-view="pitch-speed"],
  .bottom-nav-tab[data-view="metronome"] {
    display: none;
  }
}

/* --- VIEW PANEL SWITCHING (MOBILE) --- */

/* On mobile: hide all view panels, show only active */
@media (max-width: 767px) {
  .view-panel {
    display: none;
  }

  #appViewsWrapper[data-active-view="main"] .view-panel--main {
    display: block;
  }
  #appViewsWrapper[data-active-view="pitch-speed"] .view-panel--pitch-speed {
    display: block;
  }
  #appViewsWrapper[data-active-view="mixer"] .view-panel--mixer {
    display: block;
  }
  #appViewsWrapper[data-active-view="metronome"] .view-panel--metronome {
    display: block;
  }
  /* PANEL-01: Library full-screen view on mobile — overrides .collapsed transform */
  #appViewsWrapper[data-active-view="library"] .view-panel--library {
    display: block;
    transform: none;
    position: fixed;
    inset: 0;
    width: 100dvw;
    height: 100dvh;
    z-index: 200;
  }
}

/* Tablet: all main panels visible (not tab-based), library opens separately */
@media (min-width: 768px) {
  .view-panel {
    display: block;
  }
}

/* PANEL-02: Compact mixer bar (mobile only) */
.mixer-compact-bar {
  display: none; /* hidden on desktop by default */
}

@media (max-width: 767px) {
  .mixer-compact-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
  }
  .mixer-compact-label {
    font-size: 0.875rem;
    color: var(--fg-primary);
  }
  .mixer-compact-chevron {
    font-size: 0.75rem;
    color: var(--fg-muted);
    transition: transform 0.2s ease;
  }
  /* Hide stem channels by default on mobile */
  .view-panel--mixer .stem-mixer-card {
    display: none;
  }
  /* When expanded, show stem card and flip chevron */
  .view-panel--mixer.mixer-expanded .stem-mixer-card {
    display: block;
  }
  .view-panel--mixer.mixer-expanded .mixer-compact-chevron {
    transform: rotate(180deg);
  }
}

/* PANEL-02 D-10: Desktop always shows full mixer controls */
@media (min-width: 1024px) {
  .mixer-compact-bar {
    display: none !important;
  }
  .view-panel--mixer .stem-mixer-card {
    display: block !important;
  }
}

/* --- CONTAINER QUERIES (LAYOUT-04) --- */

.stem-mixer-card {
  container-type: inline-size;
  container-name: mixer;
}

/* Compact mixer layout when container is narrow (mobile tab, <400px) */
@container mixer (max-width: 400px) {
  .stem-channel {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }
  .stem-channel-label {
    width: 60px;
    font-size: 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.library-sidebar {
  container-type: inline-size;
  container-name: library;
}

/* Library compact mode when container is narrow */
@container library (max-width: 300px) {
  .library-item .text-sm {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ========================================
   PHASE 3: UPLOAD TOAST, SYNC ICONS, SORT, DELETE MODAL
   ======================================== */

/* --- UPLOAD PROGRESS TOAST --- */
.upload-toast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: 0 var(--sp-lg);
  transition: transform 0.3s ease;
}

.upload-toast.hidden {
  transform: translateY(-100%);
}

.upload-toast.error {
  border-bottom-color: #ef4444;
}

.upload-progress-track {
  flex: 1;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.upload-stage-label {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  white-space: nowrap;
}

.upload-status-text {
  font-size: var(--fs-sm);
  font-family: 'JetBrains Mono', monospace;
  color: var(--fg-muted);
  white-space: nowrap;
}

.upload-retry-btn {
  padding: 4px 10px;
  background: var(--accent-primary);
  border: none;
  border-radius: 4px;
  color: white;
  font-size: var(--fs-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.upload-retry-btn:hover {
  opacity: 0.9;
}

/* --- SYNC STATUS ICON --- */
.library-card-sync {
  font-size: var(--fs-sm);
  margin-left: 4px;
  flex-shrink: 0;
}

.library-card-sync.cached {
  color: var(--accent-secondary);
}

.library-card-sync.cloud {
  color: var(--fg-muted);
}

/* --- SONG COUNT --- */
.library-song-count {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  margin-bottom: 8px;
  display: block;
}

/* --- SORT SELECT --- */
.library-sort-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--fg-primary);
  font-size: var(--fs-sm);
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.library-sort-select:focus {
  border-color: var(--accent-primary);
}

/* --- DELETE MODAL DESTRUCTIVE BUTTON --- */
.delete-modal-btn.destructive {
  background: #ef4444;
  color: white;
}

.delete-modal-btn.destructive:hover {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Tier enforcement — Phase 5 */
.tier-limit-prompt {
  padding: var(--sp-lg);
  margin: 8px 0;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  text-align: center;
}
.tier-limit-prompt.hidden { display: none; }
.tier-limit-text {
  font-size: var(--fs-md);
  color: var(--fg-secondary, #aaa);
  margin-bottom: 12px;
}
.tier-upgrade-btn {
  background: var(--accent-primary, #ff6b35);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
}
.tier-upgrade-btn:hover {
  opacity: 0.9;
}
.song-slot-placeholder {
  height: 60px;
  margin: 4px 0;
  border: 2px dashed var(--border, #333);
  border-radius: 8px;
  background: var(--bg-secondary, #1a1a2e);
  opacity: 0.4;
}

/* Auth user header actions row */
.auth-user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.auth-settings-btn {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.auth-settings-btn:hover {
  color: var(--fg-primary);
}

/* Settings panel — Surface 3 (06-UI-SPEC) */
.settings-panel {
  padding: 0 0 16px;
  overflow-y: auto;
  flex: 1;
}
.settings-panel.hidden { display: none; }
.settings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--sp-md) var(--sp-lg);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.settings-back-btn {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
}
.settings-back-btn:hover { opacity: 0.8; }
.settings-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--fg-primary);
  margin-left: auto;
  margin-right: auto;
  padding-right: 60px; /* offset for back button */
}
.settings-section {
  padding: var(--sp-lg) var(--sp-lg) var(--sp-sm);
}
.settings-section-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: var(--fs-md);
}
.settings-row-label {
  color: var(--fg-secondary);
  font-size: var(--fs-sm);
  flex-shrink: 0;
}
.settings-row-value {
  color: var(--fg-primary);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.settings-email {
  font-size: var(--fs-sm);
  color: var(--fg-secondary);
}
.settings-name-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-primary);
  font-size: var(--fs-md);
  padding: 5px 8px;
  width: 140px;
  outline: none;
}
.settings-name-input:focus {
  border-color: var(--accent-primary);
}
.settings-save-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-primary);
  font-size: var(--fs-md);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s;
}
.settings-save-btn:hover { border-color: var(--accent-secondary); }
.settings-save-btn.hidden { display: none; }
.settings-save-msg {
  display: block;
  font-size: var(--fs-sm);
  color: var(--accent-secondary);
  margin-top: 4px;
  text-align: center;
}
.settings-save-msg.hidden { display: none; }
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 0 16px;
}
.settings-tier-free {
  font-size: var(--fs-md);
  color: var(--fg-secondary);
}
.settings-status-active {
  color: var(--accent-secondary);
  font-size: var(--fs-md);
}
.settings-status-cancelled {
  color: var(--fg-muted);
  font-size: var(--fs-md);
}
.settings-song-count {
  font-size: var(--fs-md);
}
.settings-upgrade-btn {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--accent-primary), #e55a28);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: var(--fs-md);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.settings-upgrade-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(255,107,53,0.4);
}
.settings-portal-link {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  font-size: var(--fs-sm);
  font-weight: 400;
  cursor: pointer;
  padding: 6px 0 0;
  text-align: left;
}
.settings-portal-link:hover { opacity: 0.8; }
.settings-link-btn {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  font-size: var(--fs-md);
  font-weight: 400;
  cursor: pointer;
  padding: 4px 0;
  text-align: left;
}
.settings-link-btn:hover { opacity: 0.8; }
.settings-link-btn:disabled { opacity: 0.5; cursor: default; }
.settings-loading {
  padding: var(--sp-lg);
  font-size: var(--fs-md);
  color: var(--fg-muted);
  text-align: center;
}
.settings-error {
  padding: var(--sp-lg);
  font-size: var(--fs-md);
  color: #ef4444;
  text-align: center;
}
.settings-select {
  background: var(--bg-secondary);
  color: var(--fg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: var(--fs-sm);
  cursor: pointer;
  outline: none;
}
.settings-select:focus { border-color: var(--accent-primary); }
.settings-engine-hint {
  padding: 4px 0 0;
}
.settings-hint-text {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  line-height: 1.3;
}
.engine-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.engine-label {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  white-space: nowrap;
}

/* === PHASE 13: DESKTOP COMPACT LAYOUT === */
@media (min-width: 1024px) {
  /* LAYOUT-01: Vertical stack with controlled gap */
  #appViewsWrapper {
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
  }

  /* LAYOUT-02: Compact control cards */
  .control-card {
    padding: var(--sp-sm) var(--sp-md);
  }
  .control-card-header {
    margin-bottom: var(--sp-xs);
  }
  .control-card-value {
    font-size: var(--fs-xl);
  }
  .preset-buttons {
    gap: var(--sp-xs);
    margin-bottom: 0;
  }
  .beat-dots {
    margin-bottom: var(--sp-xs);
    gap: var(--sp-sm);
  }
  .control-slider {
    margin-bottom: var(--sp-xs);
  }
  .control-slider-labels {
    margin-top: 0;
  }

  /* LAYOUT-02: Override Tailwind mb-6 on control view-panel cards */
  .view-panel--pitch-speed .control-card,
  .view-panel--mixer .control-card,
  .view-panel--metronome .control-card {
    margin-bottom: 0;
  }
}

/* LAYOUT-03: Reset button base styles (not desktop-only) */
.preset-btn--reset {
  color: var(--fg-secondary);
  font-size: var(--fs-md);
  background: transparent;
  border-color: var(--border);
}
.preset-btn--reset:hover:not(:disabled) {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}
