:root {
  --primary: #6200ea;
  --primary-light: #9d46ff;
  --primary-dark: #0a00b6;
  --text: #ffffff;
  --background: black;
  --surface: #1e1e1e;
  --surface-light: #2a2a2a;
  --error: #cf6679;
  
  /* Legacy variables for compatibility */
  --bg-color: var(--background);
  --text-color: var(--text);
  --primary-color: var(--primary-light);
  --secondary-color: var(--primary-dark);
  --accent-color: #b39ddb;
  --error-color: var(--error);
  --success-color: #4caf50;
}

body {
  font-family: 'Roboto', sans-serif;
  background-color: var(--background);
  color: var(--text);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  box-shadow: 0 0px 10px rgb(167, 1, 244, 0.5);
  margin-top: 20px;
  border-radius: 10px;
}

header {
  background-color: rgba(255, 255, 255, 0.05);
  padding: 2rem 1rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h1 {
  color: var(--primary-light);
  text-align: center;
  font-size: 3rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.subtitle {
  text-align: center;
  color: var(--accent-color);
  font-size: 1.3rem;
  margin-bottom: 0;
  padding: 0 2rem;
}

.upload-section {
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 2.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.file-input-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
  width: 100%;
  margin-bottom: 1.5rem;
}

.file-input {
  font-size: 100px;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  cursor: pointer;
}

.file-input-label {
  display: block;
  padding: 16px 24px;
  background-color: var(--primary-color);
  color: var(--text-color);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.1rem;
  font-weight: bold;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}


.selected-file {
  margin-top: 1rem;
  font-style: italic;
  text-align: center;
}

.submit-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin-top: 1.5rem;
  background-color: var(--primary-color);
  color: var(--text-color);
  border: none;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.submit-btn:hover {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 50%, var(--primary-dark) 100%);
  transform: translateY(-2px);
  box-shadow: 0 0px 20px rgba(255, 255, 255, 0.4), 0 0px 30px rgba(157, 70, 255, 0.3), inset 0 0 25px rgba(0, 0, 0, 0.2);
}

.submit-btn:disabled {
  background-color: #555;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.results-section {
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 2.5rem;
  margin-top: 2rem;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.stem-list {
  list-style-type: none;
  padding: 0;
}

.stem-item {
  background-color: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  transition: all 0.3s ease;
}

.stem-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

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

.stem-name {
  font-weight: bold;
  color: var(--accent-color);
  font-size: 1.3rem;
}

.stem-controls {
  display: flex;
  gap: 0.8rem;
}

.control-btn {
  background-color: var(--secondary-color);
  color: var(--text-color);
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.control-btn:hover {
  background-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-btn.active {
  background-color: var(--accent-color);
  color: var(--bg-color);
}

.waveform-container {
  width: 100%;
  height: 120px;
  background-color: black;
  border-radius: 8px;
  overflow: hidden;
}

.loading {
  text-align: center;
  margin-top: 2rem;
}

.loading p {
  font-size: 32px;
  font-weight: bold;
  animation: colorBlink 2s linear infinite;
}

.loading-spinner {
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 5px solid var(--primary-color);
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
  margin-bottom: 20px;
}

@keyframes colorBlink {
  0% { color: #ff0000; }
  25% { color: #00ff00; }
  50% { color: #0000ff; }
  75% { color: #ffff00; }
  100% { color: #ff0000; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.error-message, .success-message {
  text-align: center;
  margin-top: 1rem;
  padding: 1.2rem;
  border-radius: 8px;
  font-weight: bold;
}

.error-message {
  color: var(--error-color);
  background-color: rgba(255, 82, 82, 0.15);
}

.success-message {
  color: var(--success-color);
  background-color: rgba(76, 175, 80, 0.15);
}

footer {
  margin-top: auto;
  text-align: center;
  padding: 1.5rem;
  background-color: rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
}

.volume-slider {
  width: 120px;
  margin-left: 15px;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--accent-color);
  outline: none;
  border-radius: 3px;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary-color);
  cursor: pointer;
  border-radius: 50%;
}

.volume-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--primary-color);
  cursor: pointer;
  border-radius: 50%;
}

.master-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  background: linear-gradient(135deg, #0a0a0a 0%, #2a0a2a 20%, #3d1a4f 40%, #1a0a3d 60%, #4f1a3d 80%, #0a0a0a 100%);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 0px 15px rgba(255, 255, 255, 0.3), 0 0px 25px rgba(157, 70, 255, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(157, 70, 255, 0.3);
  width: 90%;
  margin-left: auto;
  margin-right: auto;
}

.master-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--primary-dark) 100%);
  color: var(--text);
  border: 2px solid rgba(157, 70, 255, 0.3);
  border-radius: 10px;
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.1rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 0px 10px rgba(255, 255, 255, 0.2), 0 0px 15px rgba(157, 70, 255, 0.1), inset 0 0 15px rgba(0, 0, 0, 0.1);
}

.master-btn:hover {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 50%, var(--primary-dark) 100%);
  transform: translateY(-2px);
  box-shadow: 0 0px 15px rgba(255, 255, 255, 0.4), 0 0px 20px rgba(157, 70, 255, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.2);
}

.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 140px;
  background-color: var(--secondary-color);
  color: var(--text-color);
  text-align: center;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -70px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.9rem;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

#reset-icon {
    position: fixed;
    top: 20px;
    left: 20px;
    font-size: 24px;
    cursor: pointer;
  z-index: 99999;
  color: var(--primary-light);
}

#reset-icon:hover {
  color: var(--primary-color);
  transform: rotate(180deg);
}


#settingsIcon {
    position: fixed;
  top: 20px;
  right: 20px;
    font-size: 20px;
    cursor: pointer;
  z-index: 99999;
  color: var(--primary-light);
}

.options-section {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
}

.options-section label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: var(--accent-color);
}



.options-section select {
  width: 100%;
  padding: 12px;
  border-radius: 6px;
  background-color: #000000;
  color: var(--text-color);
  border: 1px solid var(--accent-color);
  font-size: 1rem;
  transition: all 0.3s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  text-align: center;
  text-align-last: center;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%23ffffff" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.options-section select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(142, 36, 170, 0.3);
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  h1 {
    font-size: 2.2rem;
  }

  .subtitle {
    font-size: 1.1rem;
  }

  .upload-section, .results-section {
    padding: 1.5rem;
  }

  .submit-btn, .master-btn {
    font-size: 1rem;
    padding: 12px 20px;
  }

  .options-section {
    flex-direction: column;
    gap: 1rem;
  }

  .options-section select {
    width: 100%;
  }

  .master-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .stem-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stem-controls {
    margin-top: 1rem;
    justify-content: flex-start;
  }
}

#message {
font-size: 14px;
color: var(--text-color);
text-align: center;
}

#stemNumber {
    width: 100%;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--accent-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    text-align: center;
}

#recordButton {
  display: block;
  padding: 16px 24px;
  background-color: var(--primary-color);
  color: var(--text-color);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.1rem;
  font-weight: bold;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.file-input-label:hover,
#recordButton:hover {
  background-color: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

#recordButton.recording {
  background-color: #ff4136;
}

/* ========================================
   ENHANCED UI STYLES FOR FADR PROXY
   ======================================== */

/* Header Enhancements */
.header-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  justify-content: center;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.feature-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(45deg, var(--primary), var(--primary-dark));
  padding: 0.75rem 1.25rem;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 0px 15px rgba(255, 255, 255, 0.3), 0 0px 25px rgba(157, 70, 255, 0.2);
  transition: all 0.3s ease;
  white-space: nowrap;
  min-width: 180px;
}

.feature-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 0px 20px rgba(255, 255, 255, 0.4), 0 0px 30px rgba(157, 70, 255, 0.3), inset 0 0 25px rgba(0, 0, 0, 0.2);
}

/* Enhanced File Input */
.file-input-label {
  position: relative;
  overflow: hidden;
}

.file-input-label small {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--accent-color);
  transition: color 0.3s ease;
}

/* Enhanced Selected File Display */
.selected-file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(157, 70, 255, 0.1);
  border: 2px solid var(--primary-color);
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  animation: fileSelected 0.5s ease;
}

@keyframes fileSelected {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.selected-file-info i {
  color: var(--primary-color);
  font-size: 1.5rem;
}

.file-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-color);
}

.file-size {
  color: var(--accent-color);
  font-size: 0.9rem;
}

.clear-file-btn {
  background: rgba(255, 82, 82, 0.2);
  border: 1px solid #ff5252;
  color: #ff5252;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-file-btn:hover {
  background: #ff5252;
  color: white;
  transform: scale(1.1);
}

/* Enhanced Options Section */
.options-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: linear-gradient(135deg, #0a0a0a 0%, #2a0a2a 20%, #3d1a4f 40%, #1a0a3d 60%, #4f1a3d 80%, #0a0a0a 100%);
  border-radius: 12px;
  padding: 2rem;
  margin: 1.5rem 0;
  box-shadow: 0 0px 15px rgba(255, 255, 255, 0.3), 0 0px 25px rgba(157, 70, 255, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(157, 70, 255, 0.3);
}

.option-group {
  position: relative;
}

.option-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}

.option-group label i {
  color: var(--primary-color);
  width: 16px;
  text-align: center;
}

.help-icon {
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  margin-left: auto;
  cursor: help;
}

.option-group select {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(157, 70, 255, 0.3);
  color: var(--text-color);
  padding: 0.75rem;
  border-radius: 8px;
  width: 100%;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.option-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(157, 70, 255, 0.2);
}

.option-group select option {
  background: var(--bg-color);
  color: var(--text-color);
  padding: 0.5rem;
}

.option-description {
  display: block;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  margin-top: 0.25rem;
  font-style: italic;
}

/* Advanced Options Section */
.advanced-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: linear-gradient(135deg, #0a0a0a 0%, #2a0a2a 20%, #3d1a4f 40%, #1a0a3d 60%, #4f1a3d 80%, #0a0a0a 100%);
  margin-top: 2rem;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 0px 15px rgba(255, 255, 255, 0.3), 0 0px 25px rgba(157, 70, 255, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(157, 70, 255, 0.3);
  width: 90%;
  margin-left: auto;
  margin-right: auto;
}

.advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: linear-gradient(45deg, rgba(157, 70, 255, 0.1), rgba(74, 20, 140, 0.1));
  border: 2px solid var(--primary-color);
  color: var(--text-color);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.advanced-toggle:hover {
  background: linear-gradient(45deg, rgba(157, 70, 255, 0.2), rgba(74, 20, 140, 0.2));
  transform: translateY(-1px);
}

.advanced-options {
  margin-top: 1rem;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(157, 70, 255, 0.1);
  border-radius: 8px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    padding: 0 1.5rem;
  }
  to {
    opacity: 1;
    max-height: 500px;
    padding: 1.5rem;
  }
}

/* API and Endpoint Buttons */
.api-btn, .endpoint-btn {
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  border: none;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem;
  min-height: 44px; /* Touch-friendly minimum */
}

.api-btn:hover, .endpoint-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(157, 70, 255, 0.4);
}

.api-btn:disabled, .endpoint-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.endpoint-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Health Indicator */
.health-indicator {
  position: fixed;
  top: 100px;
  right: 20px;
  z-index: 1000;
  animation: slideInRight 0.5s ease;
}

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

.health-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.health-status.healthy {
  border-left: 4px solid #4caf50;
  color: #4caf50;
}

.health-status.unhealthy {
  border-left: 4px solid #ff5252;
  color: #ff5252;
}

.health-status small {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.7rem;
  margin-top: 0.25rem;
}

/* Enhanced Loading Section */
.loading-content {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.processing-tips {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(157, 70, 255, 0.2);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 2rem;
  text-align: left;
}

.processing-tips h4 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.processing-tips ul {
  list-style: none;
  padding: 0;
}

.processing-tips li {
  padding: 0.5rem 0;
  color: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.processing-tips li:last-child {
  border-bottom: none;
}

/* Progress Bar */
.progress-bar-container {
  margin-top: 2rem;
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

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

.progress-text {
  color: var(--primary-color);
  font-weight: bold;
  font-size: 1.1rem;
}

/* Results Section Enhancements */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.results-info {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-badge.success {
  background: rgba(76, 175, 80, 0.2);
  border: 1px solid #4caf50;
  color: #4caf50;
}

.result-badge.info {
  background: rgba(33, 150, 243, 0.2);
  border: 1px solid #2196f3;
  color: #2196f3;
}

/* Additional Mobile Optimizations */
@media (max-width: 1024px) {
  .container {
    max-width: 95%;
  }
}

/* Record Button Mobile */
@media (max-width: 768px) {
  #recordButton {
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    margin: 1.5rem 0;
    border-radius: 12px;
    width: 100%;
    min-height: 60px;
  }
  
  .record-button-container {
    margin: 1.5rem 0;
    text-align: center;
    padding: 0 1rem;
  }
}

@media (max-width: 480px) {
  #recordButton {
    padding: 1.5rem;
    font-size: 1.2rem;
    min-height: 70px;
  }
}

/* Tablet/Mobile (768px and below) */
@media (max-width: 768px) {
  .header-info {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    max-width: 100%;
    padding: 0 1rem;
    margin-left: 1rem;
    margin-right: 1rem;
  }
  
  .feature-badge {
    font-size: 0.8rem;
    padding: 0.6rem 0.8rem;
    min-width: unset;
    justify-content: center;
  }
  
  .subtitle {
    font-size: 1rem !important;
    padding: 0 1rem;
  }
  
  .container {
    padding: 1rem;
  }
  
  /* Master Controls Mobile - 2x3 Grid */
  .master-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1.25rem;
    width: 95%;
    margin-bottom: 2rem;
  }
  
  .master-btn {
    padding: 1.25rem 0.75rem;
    font-size: 1rem;
    border-radius: 10px;
    letter-spacing: 0.5px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-align: center;
  }
  
  .master-btn:nth-child(5) {
    grid-column: 1 / -1; /* Download Mix spans full width */
  }
  
  /* Stem Controls Mobile - Touch-Friendly */
  .stem-controls {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(157, 70, 255, 0.1);
  }
  
  .control-btn {
    padding: 1rem;
    font-size: 1.2rem;
    border-radius: 8px;
    min-height: 55px;
    min-width: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  .control-btn:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
  }
  
  .control-btn:active {
    transform: scale(0.95);
  }
  
  .volume-slider {
    grid-column: 1 / -1;
    width: 100% !important;
    margin: 1rem 0 0.5rem 0;
    height: 10px;
    background: rgba(157, 70, 255, 0.3);
    border-radius: 5px;
  }
  
  .volume-slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  }
  
  /* Stem Items Mobile - Enhanced Layout */
  .stem-item {
    margin-bottom: 2rem;
    padding: 1.5rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    border: 2px solid rgba(157, 70, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
  
  .stem-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
  
  .stem-name {
    font-size: 1.4rem;
    font-weight: bold;
    color: white;
    text-align: center;
    padding: 1rem;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 8px rgba(157, 70, 255, 0.3);
  }
  
  /* Waveform Mobile - Larger and More Visible */
  .waveform-container {
    margin: 1.5rem 0;
    border-radius: 12px;
    overflow: hidden;
    height: 100px !important;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(157, 70, 255, 0.2);
    padding: 0.5rem;
  }
  
  /* Song Info Mobile - Enhanced Display */
  #songInfo {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1rem;
    background: rgba(157, 70, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(157, 70, 255, 0.2);
  }
  
  #songKey, #songTempo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(45deg, rgba(157, 70, 255, 0.1), rgba(74, 20, 140, 0.1));
    border-radius: 12px;
    margin: 0.75rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    border: 1px solid rgba(157, 70, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  #songKey i, #songTempo i {
    font-size: 1.3rem;
    color: var(--primary-color);
  }
}

@media (max-width: 480px) {
  .header-info {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 0 1.5rem;
    margin-left: 0.5rem;
    margin-right: 0.5rem;
  }
  
  .feature-badge {
    font-size: 0.7rem;
    padding: 0.5rem 0.5rem;
    border-radius: 18px;
  }
  
  .subtitle {
    font-size: 0.9rem !important;
    padding: 0 1.5rem;
    line-height: 1.4;
  }
  
  .container {
    padding: 0.5rem;
  }
  
  /* Small Mobile Master Controls */
  .master-controls {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0.75rem;
  }
  
  .master-btn {
    padding: 1rem;
    font-size: 0.85rem;
    min-height: 55px;
  }
  
  /* Small Mobile Stem Controls */
  .stem-controls {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 0.5rem;
  }
  
  .control-btn {
    padding: 0.6rem;
    font-size: 0.9rem;
    min-height: 40px;
    min-width: 40px;
  }
  
  /* Small Mobile Stem Layout */
  .stem-item {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }
  
  .stem-name {
    font-size: 1.1rem;
    padding: 0.4rem;
  }
  
  .waveform-container {
    height: 70px !important;
  }
  
  /* Small Mobile Typography */
  h1 {
    font-size: 2rem !important;
  }
  
  #songKey, #songTempo {
    font-size: 0.9rem;
    padding: 0.6rem;
  }
  
  .results-header {
    flex-direction: column;
    text-align: center;
  }
  
  .results-header h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }
}
  
  
  .results-info {
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .result-badge {
    justify-content: center;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
  }
  
  .endpoint-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-top: 0.75rem;
  }
  
  .endpoint-btn {
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
    min-height: 44px;
  }
  
  .api-btn {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    min-height: 44px;
    justify-content: center;
  }
  
  .notifications-toggle.disabled {
    background: linear-gradient(45deg, #666, #444);
    opacity: 0.7;
  }
  
  .health-indicator {
    position: relative;
    top: auto;
    right: auto;
    margin: 1rem 0;
    width: 100%;
  }
  
  .health-status {
    justify-content: center;
    padding: 1rem;
    font-size: 0.85rem;
  }
  
  .selected-file-info {
    flex-direction: column;
    text-align: center;
    padding: 1rem;
    gap: 0.5rem;
  }
  
  .file-name {
    word-break: break-word;
    text-align: center;
  }
  
  .advanced-toggle {
    font-size: 1rem;
    padding: 1rem;
    min-height: 50px;
  }
  
  .advanced-options {
    padding: 1rem;
  }
  
  /* Upload Section Mobile */
  .upload-section {
    padding: 1.5rem;
    margin: 1rem auto;
    width: 95%;
  }
  
  .file-input-label {
    padding: 1.5rem;
    font-size: 1rem;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }
  
  .submit-btn {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    min-height: 55px;
    margin-top: 1.5rem;
  }
  
  /* Loading Section Mobile */
  .loading-content {
    padding: 1rem;
  }
  
  .processing-tips {
    padding: 1rem;
    margin-top: 1rem;
  }
  
  .processing-tips h4 {
    font-size: 1rem;
  }
  
  .processing-tips li {
    font-size: 0.9rem;
    padding: 0.75rem 0;
  }
}

/* Enhanced Animations */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.loading-spinner {
  animation: spin 1s linear infinite;
  width: 50px;
  height: 50px;
  border: 4px solid rgba(157, 70, 255, 0.3);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  margin: 0 auto 1rem auto;
}

@media (max-width: 768px) {
  .loading-spinner {
    width: 60px;
    height: 60px;
    border-width: 5px;
  }
}

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

/* Touch-Friendly Interactions */
@media (hover: none) and (pointer: coarse) {
  .control-btn:hover,
  .master-btn:hover,
  .api-btn:hover,
  .endpoint-btn:hover {
    transform: none; /* Disable hover effects on touch devices */
  }
  
  .control-btn:active,
  .master-btn:active {
    background: var(--secondary-color);
    transform: scale(0.95);
  }
}

/* Notification Button Styling */
.notifications-toggle {
  width: 100%;
  margin-top: 0.5rem;
}

.notifications-toggle.disabled {
  background: linear-gradient(45deg, rgba(102, 102, 102, 0.8), rgba(68, 68, 68, 0.8)) !important;
  border-color: rgba(102, 102, 102, 0.5);
}

.notifications-toggle.disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Completion Notification Popup */
.completion-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 3000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.completion-notification.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.completion-notification.hide {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
  pointer-events: none;
}

.completion-content {
  background: linear-gradient(135deg, #0a0a0a 0%, #2a0a2a 20%, #3d1a4f 40%, #1a0a3d 60%, #4f1a3d 80%, #0a0a0a 100%);
  border: 2px solid var(--primary-light);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  text-align: center;
  min-width: 350px;
  max-width: 90vw;
  box-shadow: 
    0 0px 30px rgba(255, 255, 255, 0.4), 
    0 0px 50px rgba(157, 70, 255, 0.3), 
    inset 0 0 30px rgba(0, 0, 0, 0.3),
    0 20px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  position: relative;
}

.completion-icon {
  font-size: 4rem;
  color: #4caf50;
  margin-bottom: 1rem;
  animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

.completion-content h3 {
  color: var(--primary-light);
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: bold;
}

.completion-stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: rgba(157, 70, 255, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(157, 70, 255, 0.3);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.stat i {
  color: var(--primary-light);
  font-size: 1.3rem;
}

.close-notification {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.close-notification:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  transform: scale(1.1);
}

/* Mobile Completion Notification */
@media (max-width: 768px) {
  .completion-content {
    min-width: 300px;
    padding: 2rem 1.5rem;
  }
  
  .completion-icon {
    font-size: 3rem;
  }
  
  .completion-content h3 {
    font-size: 1.5rem;
  }
  
  .stat {
    font-size: 1rem;
    padding: 0.6rem 1rem;
  }
}

@media (max-width: 480px) {
  .completion-content {
    min-width: 280px;
    padding: 1.5rem 1rem;
  }
  
  .completion-stats {
    gap: 0.75rem;
  }
  
  .stat {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
  }
  
  .completion-content h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
  }
}

/* Auto-Processing Styles */
.auto-processing-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(45deg, rgba(157, 70, 255, 0.1), rgba(74, 20, 140, 0.1));
  border: 2px solid var(--primary-light);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  margin-top: 1rem;
  animation: autoProcessPulse 2s ease-in-out infinite;
}

@keyframes autoProcessPulse {
  0%, 100% { 
    border-color: var(--primary-light);
    box-shadow: 0 0 20px rgba(157, 70, 255, 0.3);
  }
  50% { 
    border-color: var(--primary);
    box-shadow: 0 0 30px rgba(157, 70, 255, 0.5);
  }
}

.auto-processing-info i {
  color: var(--primary-light);
  font-size: 2rem;
}

.auto-info-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auto-song-name {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--primary-light);
}

.auto-song-url {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
}

.auto-progress {
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auto-complete-info {
  margin-bottom: 1rem;
}

.stat.highlight {
  background: linear-gradient(45deg, var(--primary), var(--primary-light));
  border-color: var(--primary-light);
  color: white;
  font-weight: bold;
}

/* Enhanced Focus Styles for Accessibility */
button:focus,
select:focus,
input:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Smooth Transitions for All Interactive Elements */
* {
  transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

/* Mobile Viewport Optimization */
@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
  }
  
  body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Prevent zoom on form focus */
  input, select, textarea {
    font-size: 16px !important;
  }
  
  /* Safe area padding for notched devices */
  .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  
  header {
    padding-top: max(2rem, env(safe-area-inset-top));
  }
}

/* Enhanced Error and Success Messages */
.error-message {
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid #f44336;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  color: #ff5252;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .error-message, .success-message {
    padding: 1rem;
    margin: 1rem 0.5rem;
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .error-message, .success-message {
    padding: 1.25rem;
    margin: 1rem 0.25rem;
    font-size: 1rem;
    flex-direction: column;
    text-align: center;
  }
  
  .error-message::before, .success-message::before {
    font-size: 1.5rem;
    margin: 0;
  }
}

.error-message::before {
  content: "⚠️";
  font-size: 1.2rem;
  margin-top: 0.1rem;
}

.success-message {
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid #4caf50;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  color: #66bb6a;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.success-message::before {
  content: "✅";
  font-size: 1.2rem;
  margin-top: 0.1rem;
}

/* Auto-Muted Instrumental Track Styling */
.control-btn.active[title*="Mute"] {
  background: linear-gradient(45deg, #f44336, #d32f2f) !important;
  border-color: #f44336;
  box-shadow: 0 0 10px rgba(244, 67, 54, 0.3);
  color: white;
}

.stem-item[data-auto-muted="true"] {
  border-color: rgba(255, 152, 0, 0.4);
  opacity: 0.8;
}

.stem-item[data-auto-muted="true"] .stem-name {
  color: rgba(255, 255, 255, 0.7);
}

/* Mixing Tip Styling */
.mixing-tip {
  background: linear-gradient(45deg, rgba(255, 193, 7, 0.1), rgba(255, 152, 0, 0.1));
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  margin: 1rem 0 2rem 0;
}

.tip-content {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.tip-content i {
  color: #ffc107;
  font-size: 1.5rem;
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.tip-text {
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
  font-size: 0.95rem;
}

.tip-text strong {
  color: #ffc107;
}

@media (max-width: 768px) {
  .mixing-tip {
    padding: 1rem;
    margin: 1rem 0.5rem 1.5rem 0.5rem;
  }
  
  .tip-content {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }
  
  .tip-text {
    font-size: 0.9rem;
  }
}

