:root {
  --primary: #ff006e;
  --primary-hover: #e6006a;
  --bg-app-top: #EE8DE0;
  --bg-app-bottom: #D190DF;
  --bg-player: #1F304B;
  --bg-voices-top: #1F304B;
  --bg-voices-bottom: #98388B;
  --text-white: #ffffff;
  --text-gray: #b0b0b0;
  --slider-bg: #2d2d3d;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg-app-top) 0%, var(--bg-app-bottom) 100%);
  color: var(--text-white);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.app-container {
  max-width: 420px;
  margin: 40px auto;
  background: var(--bg-player);
  height: calc(100vh - 80px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  position: relative;
  border-radius: 30px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Badge de version (bas droite) */
.version-badge {
  position: fixed;
  bottom: 70px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: rgba(255, 255, 255, 0.9);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  z-index: 9998;
  pointer-events: none;
  user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Player bar - Fixed en haut */
.player-bar {
  position: relative;
  width: 100%;
  background: var(--bg-player);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 16px;
  z-index: 1050;
  flex-shrink: 0;
}

.song-title {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  color: var(--text-white);
}

.part-select-container {
  text-align: center;
  margin-bottom: 12px;
}

.part-select {
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 6px 32px 6px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-white);
  cursor: pointer;
  transition: all 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.part-select:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.15);
}

.timeline-section {
  margin-bottom: 12px;
}

.current-part-name {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: 4px;
  min-height: 18px;
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-gray);
  margin-bottom: 6px;
}

.timeline-bar {
  height: 20px;
  background: #536A81;
  border-radius: 4px;
  position: relative;
  overflow: visible;
  cursor: pointer;
}

.timeline-bar.chapter-mode {
  background: transparent;
  display: flex;
  gap: 3px;
}

.timeline-chapter {
  height: 100%;
  background: #536A81;
  border-radius: 3px;
  position: relative;
  transition: background-color 0.2s;
  flex-shrink: 0;
  cursor: pointer;
  padding: 2px 0;
  margin: -2px 0;
}

.timeline-chapter.active {
  background: rgba(255, 255, 255, 0.5);
}

.timeline-chapter:hover {
  background: rgba(255, 255, 255, 0.3);
}

.timeline-chapter-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.05s linear;
  pointer-events: none;
}

.timeline-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.05s linear;
  box-shadow: none;
  pointer-events: none;
  z-index: 2;
}

.timeline-loop-region {
  position: absolute;
  top: 0;
  height: 100%;
  background: white;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 1;
}

.timeline-loop-region.active {
  opacity: 0.6;
}

.timeline-loop-left-mask {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #2d3b4e;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 1;
}

.timeline-loop-left-mask.active {
  opacity: 0.8;
}

.timeline-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: white;
  border: 2px solid var(--primary);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 3;
}

.timeline-bar:hover .timeline-handle {
  opacity: 1;
}

.timeline-bar.seeking .timeline-handle {
  opacity: 1;
}

.loop-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 16px;
  background: transparent;
  border-left: 2px solid var(--primary);
  border-right: 2px solid var(--primary);
  cursor: grab;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 10;
}

.loop-handle::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 2px;
  height: 4px;
  background: var(--primary);
}

.loop-handle::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: -2px;
  width: 2px;
  height: 4px;
  background: var(--primary);
}

.loop-handle.active {
  opacity: 1;
}

.loop-handle:active {
  cursor: grabbing;
}

.player-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.control-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: none;
}

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

.control-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.control-btn:not(.disabled):hover {
  transform: translateY(-2px);
  background: var(--primary-hover);
}

.secondary-btn {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: var(--text-white);
  font-size: 1.2rem;
  box-shadow: none;
}

.secondary-btn.active {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
}

.secondary-btn:hover {
  border-color: var(--primary);
  background: rgba(255, 0, 110, 0.2);
  transform: none;
}

.secondary-btn.active:hover {
  background: var(--primary) !important;
}

.secondary-btn:focus {
  outline: none;
}

/* Main content - Zone scrollable */
main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: linear-gradient(180deg, var(--bg-voices-top) 0%, var(--bg-voices-bottom) 100%);
}

main::-webkit-scrollbar {
  width: 6px;
}

main::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

main::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

main::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Table des voix */
.voice-table {
  width: 100%;
  border-collapse: collapse;
}

.voice-table tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.voice-table tr:last-child {
  border-bottom: none;
}

.voice-table tr.muted {
  opacity: 0.4;
}

.voice-table td {
  padding: 14px 16px;
  vertical-align: middle;
}

.voice-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.voice-meter-column {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  flex-shrink: 0;
}

.volume-meter {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  height: auto;
  align-items: center;
  justify-content: center;
}

.volume-meter-bar {
  width: 20px;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
  transition: background-color 0.1s ease;
}

.volume-meter-bar.active {
  background: white;
}

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

.voice-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-white);
  margin-bottom: 6px;
}

.volume-display {
  font-size: 0.75rem;
  color: var(--text-white);
  font-weight: 600;
}

.voice-controls {
  display: flex;
  flex-direction: row;
  gap: 8px;
  flex-shrink: 0;
}

.voice-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-white);
}

.voice-btn:active {
  transform: scale(0.9);
}

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

.voice-btn.mute-btn.muted {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.volume-slider-container {
  margin-top: 8px;
  position: relative;
}

.volume-slider {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, white var(--slider-percent, 100%), #536A81 var(--slider-percent, 100%));
  outline: none;
  -webkit-appearance: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: none;
}

.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: none;
}

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

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 1;
  color: var(--text-white);
}

/* Loader */
.loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(31, 48, 75, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loader-text {
  margin-top: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-white);
}

#voiceSection {
  padding: 16px;
}

/* Offcanvas */
.offcanvas {
  max-width: 320px;
  background: var(--bg-player);
  color: var(--text-white);
  z-index: 2000;
}

.offcanvas-backdrop {
  z-index: 1999;
}

.offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-close {
  filter: invert(1);
}

.song-list-item {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 0.15s;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-white);
}

.song-list-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.song-list-item.active {
  background: rgba(255, 0, 110, 0.3);
  color: var(--text-white);
  font-weight: 700;
  border-left: 4px solid var(--primary);
}

/* Toast container */
.toast-container {
  position: fixed !important;
  top: 16px !important;
  right: 16px !important;
  z-index: 2000 !important;
  max-width: 350px;
}

.toast {
  background: var(--bg-player);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  margin-bottom: 12px;
  color: var(--text-white);
}

.toast.toast-success {
  border-left: 4px solid #10b981;
}

.toast.toast-error {
  border-left: 4px solid #ef4444;
}

.toast.toast-warning {
  border-left: 4px solid #f59e0b;
}

.toast-body {
  padding: 12px 16px;
  color: var(--text-white);
  font-weight: 600;
  font-size: 0.9rem;
}

.toast .btn-close {
  filter: invert(1);
}

/* Mobile */
@media (max-width: 480px) {
  body {
    background: var(--bg-player);
  }
  
  .app-container {
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    height: 100vh;
  }
  
  .toast-container {
    left: 16px;
    right: 16px;
    max-width: calc(100% - 32px);
  }
}

@media (max-width: 576px) {
  .control-btn {
    width: 58px;
    height: 58px;
    font-size: 1.6rem;
  }
  
  .secondary-btn {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }
}