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

body {
  font-family: Arial, sans-serif;
  line-height: 1.6;
  padding: 20px;
  background: #f0f0f0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

h1 {
  text-align: center;
  margin-bottom: 20px;
  color: #333;
}

.controls {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.member-controls, .song-controls {
  display: none; 
  gap: 10px;
  flex: 1;
}

.song-controls {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 300px;
}

input {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

button {
  padding: 8px 16px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s;
}

button:hover {
  background: #45a049;
}

.member-container {
  position: relative;
  display: inline-block;
}

.member-name-edit {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  background: white;
}

.member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.member {
  padding: 8px 16px;
  border-radius: 20px;
  color: white;
  cursor: pointer;
  transition: opacity 0.3s;
}

.member:hover {
  opacity: 0.8;
  cursor: pointer;
}

.member:after {
  content: '✎';
  margin-left: 5px;
  font-size: 0.8em;
  opacity: 0;
  transition: opacity 0.3s;
}

.member:hover:after {
  opacity: 0.7;
}

.member-name-input {
  min-width: 120px;
  padding: 8px 12px;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.3s ease;
  background: white;
}

.member-name-input:hover {
  border-color: #7c4dff;
}

.member-name-input:focus {
  border-color: #6200ea;
  outline: none;
  box-shadow: 0 0 0 3px rgba(98, 0, 234, 0.2);
}

.member-name-input::placeholder {
  color: #999;
  font-style: italic;
}

.member-color-input {
  width: 40px;
  height: 30px;
  padding: 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.delete-member {
  background: #ff4444;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.delete-member:hover {
  background: #ff0000;
}

.add-member-btn {
  width: auto;
  padding: 8px 16px;
  margin: 10px auto;
  display: block;
  background: #6200ea;
  font-size: 14px;
}

.add-member-btn:hover {
  background: #7c4dff;
}

.selected-member {
  margin: 20px 0;
  text-align: center;
  font-weight: bold;
}

.timeline-container {
  margin: 20px 0;
  position: relative;
}

.timeline {
  height: 60px;  
  background: #eee;
  position: relative;
  border-radius: 4px;
  overflow: visible; 
  margin-top: 20px; 
}

.timeline-segment {
  position: absolute;
  height: 100%;
  top: 0;
  transition: opacity 0.3s;
}

.segment-label {
  position: absolute;
  top: -20px;
  left: 0;
  white-space: nowrap;
  font-size: 12px;
  font-weight: bold;
  transform: translateX(-50%);
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.timeline-segment:hover {
  opacity: 0.8;
}

.timeline-segment.current {
  position: absolute;
  height: 100%;
  top: 0;
  box-shadow: inset 0 0 0 2px #fff;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: inset 0 0 0 2px #fff;
  }
  50% {
    box-shadow: inset 0 0 0 4px #fff;
  }
  100% {
    box-shadow: inset 0 0 0 2px #fff;
  }
}

.time-markers {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: #666;
  font-size: 12px;
}

.distribution-stats {
  margin-top: 30px;
}

.distribution-chart {
  margin-top: 20px;
}

.distribution-bar {
  margin: 20px 0;
  display: flex;
  align-items: center;
  gap: 15px;
  position: relative;
  padding: 10px;
  background: #f8f8f8;
  border-radius: 8px;
  transition: background 0.3s ease;
}

.distribution-bar:hover {
  background: #f0f0f0;
}

.bar-label {
  min-width: 100px;
}

.bar {
  height: 30px;  
  transition: width 0.3s;
  border-radius: 4px;
  position: relative;
}

.bar::before {
  content: attr(data-time);
  position: absolute;
  top: -20px;
  right: 0;
  font-size: 12px;
  font-weight: bold;
}

.percentage {
  margin-left: 10px;
  white-space: nowrap;
  color: #666;
}

.export-controls {
  margin-top: 20px;
  text-align: center;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
}

.timer {
  font-family: monospace;
  font-size: 1.2em;
  min-width: 70px;
}

.progress-bar-container {
  flex-grow: 1;
  height: 10px;
  background: #eee;
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: #4CAF50;
  transition: width 0.1s linear;
}

#playPauseBtn {
  font-size: 1.5em;
  min-width: 50px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.primary-add-button {
  background: #6200ea;
  color: white;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

.primary-add-button:hover {
  background: #7c4dff;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

.popup input {
  margin-bottom: 15px;
  width: 100%;
  padding: 10px;
}

.popup-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.member-action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.add-segment-btn {
  background: #2196F3;
}

.add-segment-btn:hover {
  background: #1976D2;
}

.member-timers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
  transition: all 0.3s ease;
}

.member-timer {
  display: grid;
  grid-template-columns: 120px 1fr 80px 40px 60px auto 120px 180px !important;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px;
  background: #f8f8f8;
  border-radius: 8px;
  transition: transform 0.3s ease;
}

.member-timer > div:first-child {
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer-bar-container {
  height: 20px;
  background: #eee;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.timer-bar {
  height: 100%;
  width: 0;
  transition: width 0.1s linear;
}

.timer-display {
  font-family: monospace;
  font-size: 1.2em;
  text-align: right;
  white-space: nowrap;
}

.timer-button {
  padding: 5px;
  font-size: 1.2em;
  min-width: 40px;
  height: 40px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-button:hover {
  background: #45a049;
}

.timer-button[data-state="paused"] {
  background: #2196F3;
}

.timer-button[data-state="paused"]:hover {
  background: #1976D2;
}

.timer-button[data-state="new-part"] {
  background: #ff9800;
}

.timer-button[data-state="new-part"]:hover {
  background: #f57c00;
}

.lap-time {
  font-family: monospace;
  font-size: 0.9em;
  color: #666;
}

.lap-display {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8em;
  color: #666;
  max-height: 150px !important;
  overflow-y: auto;
  padding: 8px !important;
}

.lap-average {
  background: #e3f2fd;
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-weight: bold;
  color: #1976d2;
  border-left: 3px solid #1976d2;
}

.lap {
  padding: 2px 4px;
  margin: 2px 0;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 2px;
  font-size: 0.9em;
}

.pie-chart-container {
  margin-top: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.pie-chart {
  width: 300px;
  height: 300px;
  position: relative;
}

.pie-chart-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.legend-text {
  display: flex;
  gap: 8px;
  align-items: center;
}

.legend-text span:last-child {
  color: #666;
  font-size: 0.9em;
}

.reset-btn {
  background: #ff4444;
}

.reset-btn:hover {
  background: #ff0000;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: white;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.modal h2 {
  margin-bottom: 20px;
}

.save-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-weight: bold;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.saved-songs {
  margin-top: 20px;
  border-top: 1px solid #ddd;
  padding-top: 20px;
}

.saved-song {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #f5f5f5;
  margin-bottom: 10px;
  border-radius: 4px;
}

.saved-song-info {
  flex-grow: 1;
}

.saved-song-actions {
  display: flex;
  gap: 10px;
}

.load-btn {
  background: #2196F3;
}

.load-btn:hover {
  background: #1976D2;
}

.delete-btn {
  background: #ff4444;
}

.delete-btn:hover {
  background: #ff0000;
}

.save-controls {
  margin-top: 20px;
  text-align: center;
}

.keyboard-shortcut {
  font-size: 0.8em;
  color: #666;
  margin-left: 10px;
  padding: 2px 6px;
  background: #f0f0f0;
  border-radius: 3px;
  display: inline-block;
}

.microphone-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 8px;
}

#microphoneBtn {
  background: #6200ea;
  color: white;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: bold;
  transition: all 0.3s ease;
}

#microphoneBtn:hover {
  background: #7c4dff;
}

#microphoneBtn.active {
  background: #F44336;
}

#microphoneBtn.active:hover {
  background: #d32f2f;
}

#audioVisualizer {
  width: 100%;
  height: 100px;
  background: #2c2c2c;
  border-radius: 4px;
  display: block;
}

.visualizer-container {
  flex-grow: 1;
  position: relative;
  background: #2c2c2c;
  border-radius: 4px;
  overflow: hidden;
}

.visualizer-label {
  position: absolute;
  right: 10px;
  top: 5px;
  color: #888;
  font-size: 12px;
}

.highest-notes {
  margin-top: 5px;
  font-size: 0.9em;
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.notes-display {
  display: flex;
  gap: 20px;
  margin-top: 5px;
}

.notes-section {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.notes-section strong {
  margin-right: 5px;
}

.high-note, .low-note {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
  transition: opacity 0.3s ease;
}

.high-note {
  border-left: 2px solid #4CAF50;
}

.low-note {
  border-left: 2px solid #2196F3;
}

.lap-group {
  margin: 8px 0;
  padding: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  border-left: 3px solid #1976d2;
}

.group-header {
  font-weight: bold;
  color: #1976d2;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ddd;
}

.group-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.group-range-input {
  width: 60px;
  padding: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.group-name-input {
  width: 120px;
  padding: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.add-group-btn {
  background: #ff9800;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
}

.add-group-btn:hover {
  background: #f57c00;
}

.part-group {
  background: #fff3e0;
  padding: 8px;
  border-radius: 4px;
  margin: 8px 0;
  border-left: 3px solid #ff9800;
}

.part-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ffe0b2;
}

.part-group-title {
  font-weight: bold;
  color: #e65100;
}

.part-group-total {
  color: #f57c00;
}

.delete-group-btn {
  background: #ff5252;
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-group-btn:hover {
  background: #ff1744;
}