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

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(45deg, #1a1a1a, #4a4a4a);
  padding: 1rem;
}

.player-container {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 800px;
  height: 80vh;
  max-height: 600px;
  min-height: 400px;
  display: flex;
  overflow: hidden;
  position: relative;
}

.main-player {
  flex: 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow: hidden;
  transition: all 0.3s ease;
}

.playlist {
  width: 35%;
  min-width: 200px;
  max-width: 50%;
  background: #f4f4f4;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #ddd;
  transition: all 0.3s ease;
  position: relative;
}

/* 播放清單折疊狀態 */
.playlist.collapsed {
  width: 50px;
  min-width: 50px;
  padding: 0.5rem;
}

/* 播放清單展開狀態 */
.playlist.expanded {
  width: 50%;
  max-width: 60%;
}

/* 播放清單調整按鈕 */
.playlist-resize {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 60px;
  background: #4caf50;
  border: none;
  border-radius: 0 4px 4px 0;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.playlist-resize .material-icons {
  font-size: 18px;
}

/* 隱藏播放清單內容 */
.playlist.collapsed .playlist-content,
.playlist.collapsed .playlist-header,
.playlist.collapsed .playlist-tools {
  display: none;
}

/* 折疊時顯示的垂直文字 */
.playlist-collapsed-title {
  display: none;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  white-space: nowrap;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(180deg);
  font-weight: bold;
  color: #666;
}

.playlist.collapsed .playlist-collapsed-title {
  display: block;
}

/* 修改播放清單內容區域的樣式，確保在小螢幕上有滾動條 */
.playlist-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  max-height: calc(100% - 100px);
  min-height: 100px;
}

.current-track {
  text-align: center;
  padding: 0.5rem;
  margin: 0.5rem 0;
  background: #f8f8f8;
  border-radius: 4px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.title {
  text-align: center;
  margin-bottom: 1rem;
  color: #333;
  font-size: 1.2rem;
}

/* 控制區塊相關樣式 */
.controls-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin: 0.5rem 0;
}

.controls-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.btn {
  padding: 0.4rem;
  border: none;
  border-radius: 4px;
  background: #4caf50;
  color: white;
  cursor: pointer;
  transition: background 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  font-size: 0.9rem;
}

.btn .material-icons {
  font-size: 24px;
}

.btn:hover {
  background: #45a049;
}

.btn-mode {
  background: #666;
}

.btn-mode.active {
  background: #4caf50;
}

/* 進度條相關樣式 */
.progress-container {
  width: 100%;
  height: 5px;
  background: #ddd;
  border-radius: 5px;
  cursor: pointer;
  margin: 0.5rem 0;
}

.progress-bar {
  height: 100%;
  background: #4caf50;
  border-radius: 5px;
  width: 0%;
}

.time-display {
  display: flex;
  justify-content: space-between;
  color: #666;
  font-size: 0.8rem;
  padding: 0 0.5rem;
}

/* 速度和音量控制區塊 */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: #f8f8f8;
  border-radius: 4px;
}

.control-group .material-icons {
  min-width: 24px;
}

.speed-select {
  padding: 0.2rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  width: 80px;
}

.volume-slider {
  flex: 1;
  max-width: 120px;
}

.volume-value {
  min-width: 45px;
  text-align: right;
}

/* 播放清單相關樣式 */
.playlist-header {
  font-size: 1.1rem;
  border-bottom: 2px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

/* 工具切換按鈕樣式 */
.tool-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  border-radius: 50%;
  transition: background 0.2s;
}

.tool-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.tool-toggle-btn .material-icons {
  font-size: 20px;
}

/* 動態位置新增按鈕樣式 */
.add-music-btn.dynamic-position {
  position: absolute;
  z-index: 100;
  /* 預設樣式（右下角） */
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

/* 空播放清單時的按鈕樣式（置中） */
.playlist-empty .add-music-btn.dynamic-position {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  font-size: 1.5rem;
}

.playlist.collapsed .add-music-btn.dynamic-position {
  display: none;
}

.add-music-btn {
  font-size: 0.9rem;
  padding: 0.3rem 0.6rem;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.add-music-btn:hover {
  background: #45a049;
}

.playlist-item {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-bottom: 1px solid #ddd;
  cursor: pointer;
  transition: background 0.2s;
}

.playlist-item:hover {
  background: #e0e0e0;
}

.playlist-item.active {
  background: #4caf50;
  color: white;
}

.playlist-item-number {
  margin-right: 0.5rem;
  font-weight: bold;
  min-width: 24px;
}

.playlist-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 0.5rem;
}

.playlist-item-name.multiline {
  white-space: normal;
  word-break: break-all;
}

.playlist-item-remove {
  opacity: 0.7;
  cursor: pointer;
  padding: 0 0.3rem;
  font-size: 1.2rem;
}

.playlist-item-remove:hover {
  opacity: 1;
}

/* 添加音樂對話框 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-title {
  font-size: 1.2rem;
  font-weight: bold;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

.input-group {
  margin-bottom: 1rem;
}

.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: #666;
}

.url-textarea {
  width: 100%;
  height: 100px;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  resize: vertical;
  font-family: inherit;
}

.file-input-wrapper {
  margin-bottom: 1rem;
}

/* 工具列控制項樣式 */
.toolbar-control {
  display: flex;
  align-items: center;
  margin-left: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  padding: 2px 4px;
}

.control-label {
  display: flex;
  align-items: center;
  margin-right: 4px;
  color: #555;
}

.control-label .material-icons {
  font-size: 18px;
}

.toolbar-select {
  border: none;
  background: transparent;
  font-size: 12px;
  padding: 2px;
  color: #333;
  cursor: pointer;
  outline: none;
}

@media (max-width: 768px) {
  .player-container {
    flex-direction: column;
    height: 100vh;
    max-height: none;
    min-height: 100vh;
  }

  .main-player {
    flex: 1;
    width: 100%;
    min-height: 50vh;
    padding: 1rem;
    display: flex;
    flex-direction: column;
  }

  .playlist {
    flex: 1;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    border-left: none;
    border-top: 1px solid #ddd;
    min-height: 30vh;
    overflow-y: auto;
  }

  body {
    padding: 0;
    overflow: hidden;
  }

  .playlist-content {
    flex: 1;
    overflow-y: auto;
  }

  .playlist-resize {
    display: none;
  }

  .btn {
    padding: 0.3rem;
  }

  .btn .material-icons {
    font-size: 20px;
  }

  /* 行動裝置上的按鈕樣式調整 */
  .add-music-btn.dynamic-position {
    bottom: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
  }

  .playlist-empty .add-music-btn.dynamic-position {
    width: 55px;
    height: 55px;
  }
  
  .toolbar-control {
    margin-left: 4px;
    padding: 1px 2px;
  }
  
  .toolbar-select {
    font-size: 11px;
    max-width: 50px;
  }
  
  .control-label .material-icons {
    font-size: 16px;
  }
}

/* 針對移動設備特別優化 */
@media (max-width: 768px) {
  .playlist-content {
    max-height: calc(100% - 80px);
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* 確保播放清單容器本身也有正確的高度和滾動設定 */
  .playlist {
    display: flex;
    flex-direction: column;
    max-height: 50vh;
    overflow: hidden;
  }

  /* 確保在折疊狀態下不顯示滾動條 */
  .playlist.collapsed .playlist-content {
    overflow: hidden;
  }
}

/* 針對特別小的螢幕做額外調整 */
@media (max-width: 480px) and (orientation: portrait) {
  .player-container {
    height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .main-player {
    min-height: 60vh;
  }

  .playlist {
    min-height: 40vh;
  }
  
  .playlist-content {
    max-height: calc(100% - 70px);
  }
}

/* 確保在 iPhone 等設備上也能正確顯示 */
@media screen and (max-height: 812px) and (orientation: portrait) {
  .player-container {
    height: -webkit-fill-available;
    min-height: -webkit-fill-available;
  }
}

@media (min-width: 544px) and (max-width: 768px) {
  .player-container {
    max-height: 90vh;
  }

  .main-player,
  .playlist {
    max-height: 100%;
  }
}

/* 確保在橫向模式下也能正確顯示 */
@media (orientation: landscape) and (max-width: 768px) {
  .player-container {
    flex-direction: row;
    height: 80vh;
  }

  .main-player {
    flex: 0 0 65%;
  }

  .playlist {
    flex: 0 0 35%;
    border-left: 1px solid #ddd;
    border-top: none;
  }
  
  .playlist-content {
    max-height: calc(100% - 80px);
  }
}

.tab-container {
  margin-bottom: 1rem;
}

.tab-buttons {
  display: flex;
  margin-bottom: 1rem;
  border-bottom: 2px solid #ddd;
}

.tab-button {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  color: #666;
}

.tab-button.active {
  color: #4caf50;
  border-bottom: 2px solid #4caf50;
  margin-bottom: -2px;
}

.tab-content {
  display: none;
}

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

.add-music-btn + .add-music-btn {
  margin-left: 0.5rem;
}

.playlist-item-checkbox {
  margin-right: 8px;
  cursor: pointer;
}

.settings-panel {
  position: fixed;
  top: 0;
  left: -300px;
  width: 300px;
  height: 100vh;
  background: white;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  transition: left 0.3s ease;
  z-index: 1000;
  max-width: 350px;
  border-radius: 0px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  background: #fff;
  overflow: hidden;
}

.settings-panel.show {
  left: 0;
}

.settings-header {
  display: flex;
  align-items: center;
  padding: 16px;
  background: #4caf50;
  color: white;
}

.settings-header h2 {
  margin: 0;
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
}

.close-settings {
  background: none;
  border: none;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.2s;
}

.close-settings:hover {
  background: rgba(255, 255, 255, 0.2);
}

.settings-content {
  padding: 16px;
  max-height: 80vh;
  overflow-y: auto;
}

/* 滾動條整體樣式 */
.settings-content::-webkit-scrollbar {
  width: 6px;
}

/* 滾動條軌道 */
.settings-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

/* 滾動條滑塊 */
.settings-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  transition: background 0.3s;
}

/* 滾動條滑塊懸停效果 */
.settings-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

.settings-group {
  margin-bottom: 24px;
}

.settings-heading {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f5f5f5;
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item-label {
  font-size: 14px;
  color: #333;
}

.settings-item-control {
  display: flex;
  align-items: center;
}

.settings-select {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  min-width: 100px;
  font-size: 14px;
  color: #333;
}

.range-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}

.range-control input[type="range"] {
  flex: 1;
  height: 5px;
  background: #ddd;
  border-radius: 2px;
  -webkit-appearance: none;
}

.range-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4caf50;
  cursor: pointer;
}

.range-control span {
  min-width: 40px;
  text-align: right;
  font-size: 14px;
  color: #666;
}

/* 確保設定面板在小屏幕上也能正常顯示 */
@media (max-height: 600px) {
  .settings-content {
    max-height: 70vh;
  }
}

.playlist-tools {
  padding: 0.2rem 0 0.4rem 0;
  background: #f0f0f0;
  gap: 0.5rem;
  display: flex;
  justify-content: center;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding-top: 0;
  padding-bottom: 0;
}

/* 工具列展開狀態 */
.playlist-tools.expanded {
  max-height: 50px;
  padding-top: 0.2rem;
  padding-bottom: 0.4rem;
}

.tool-btn {
  padding: 0.3rem;
  background: #f0f0f0;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  color: #666;
  font-size: 0.8rem;
  align-items: center;
}

.tool-btn:hover {
  background: #e0e0e0;
}

.tool-btn .material-icons {
  font-size: 18px;
}

.tool-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #ddd;
}

.base-path-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-top: 0.3rem;
}

.file-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.clear-btn {
  flex: 1;
  padding: 0.5rem;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.clear-btn:hover {
  background: #d32f2f;
}

.url-confirm-btn {
  flex: 1;
  padding: 0.5rem;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.url-confirm-btn:hover {
  background: #45a049;
}

.file-info {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8f8f8;
  border-radius: 4px;
}

.file-count {
  margin-bottom: 0.5rem;
  font-weight: bold;
}

.file-list {
  max-height: 100px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.file-list-item {
  padding: 0.3rem 0;
  border-bottom: 1px solid #eee;
}

/* 聲波圖相關樣式 */
.waveform-container {
  width: 100%;
  margin: 0.5rem 0 1rem 0;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}

.waveform-canvas {
  width: 100%;
  height: 120px;
  background-color: #f8f8f8;
  cursor: pointer;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.waveform-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.waveform-btn {
  padding: 0.3rem;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 3px;
  cursor: pointer;
  color: #666;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.waveform-btn:hover {
  background: #e0e0e0;
}

.waveform-btn.active {
  background: #4caf50;
  color: white;
  border-color: #4caf50;
}

.waveform-title {
  font-size: 0.9rem;
  font-weight: bold;
  color: #666;
  margin-right: auto;
}

.waveform-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

/* 開關按鈕樣式 */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
}

input:checked + .slider {
  background-color: #4caf50;
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 22px;
}

.slider.round:before {
  border-radius: 50%;
}

/* 美化滾動條樣式 */
.playlist-content::-webkit-scrollbar {
  width: 6px;
}

.playlist-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.playlist-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.playlist-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* =========================================
   滿版模式 (填滿瀏覽器視窗) 樣式
   ========================================= */
body.fullscreen-mode {
  padding: 0;
  background: #1a1a1a; /* 配合你原本的深色背景 */
}

body.fullscreen-mode .player-container {
  max-width: 100%;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  box-shadow: none;
}

body.fullscreen-mode .main-player {
  flex: 1;
}

body.fullscreen-mode .waveform-canvas {
  height: 200px; 
}