:root {
  --primary: #4f46e5;
  --primary-light: rgba(79, 70, 229, 0.12);
  --primary-dark: #4338ca;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #6b7280;
  --surface-alpha: rgba(255, 255, 255, 0.5);
  --border: rgba(0,0,0,0.06);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius: 16px;
  --radius-lg: 20px;
  --header-h: 52px;
  --controls-h: 160px;
  --mini-h: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-elevated: #2c2c2e;
    --text: #ffffff;
    --text-secondary: #8e8e93;
    --surface-alpha: rgba(28, 28, 30, 0.5);
    --border: rgba(255,255,255,0.08);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
    --primary-light: rgba(99, 102, 241, 0.2);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ===== 视图系统 ===== */
.view {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 1;
}
.view.active {
  transform: translateX(0);
  z-index: 2;
}

/* ===== 列表视图 ===== */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* ===== 列表工具栏 ===== */
.list-toolbar {
  display: flex;
  gap: 10px;
  padding: 0 16px 10px;
  align-items: center;
  background: var(--bg);
  position: sticky;
  top: var(--header-h);
  z-index: 10;
}
.search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-secondary);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.search-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
.sort-select {
  height: 38px;
  padding: 0 30px 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  flex-shrink: 0;
}
.sort-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.track-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}

.list-main {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  padding-bottom: calc(var(--mini-h) + var(--safe-bottom) + 16px);
}

.track-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.track-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
}
.track-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow);
}
.track-header {
  display: flex;
  gap: 12px;
  align-items: center;
}
.track-cover {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: 600;
  flex-shrink: 0;
}
.track-info {
  flex: 1;
  min-width: 0;
}
.track-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
  align-items: center;
}
.track-meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-secondary);
  opacity: 0.5;
}
.track-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.track-progress {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.track-progress-inner {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}
.track-progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== 播放器视图 ===== */
.player-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg);
  z-index: 10;
}
.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px; min-height: 40px;
  border-radius: 50%;
  transition: background 0.15s;
}
.icon-btn:active { background: var(--border); }
.player-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
  color: var(--text-secondary);
}

.player-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.subtitle-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
}

.subtitle-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 16px;
  box-sizing: border-box;
}

.subtitle-item {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1.6;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  user-select: none;
  color: var(--text-secondary);
  border: 1px solid transparent;
  text-align: center;
  opacity: 0.25;
  transform: scale(0.95);
}
.subtitle-item:active {
  background: var(--surface-elevated);
}
.subtitle-item.active {
  opacity: 1;
  transform: scale(1);
  background: none;
  border: 1px solid transparent;
  color: var(--primary);
  font-size: 20px;
  font-weight: 600;
  padding: 14px 20px;
  box-shadow: 0 2px 12px rgba(79, 70, 229, 0.15);
}
.subtitle-item.prev-active,
.subtitle-item.next-active {
  opacity: 0.45;
  transform: scale(0.97);
  color: var(--text);
}

.player-controls {
  position: relative;
  background: var(--surface-alpha);
  border-top: 1px solid var(--border);
  padding: 16px 20px calc(16px + var(--safe-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
}

.progress-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.progress-area span {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  touch-action: none;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
  pointer-events: none;
}
.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 16px; height: 16px;
  background: var(--primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
  transition: left 0.1s linear, transform 0.15s;
  opacity: 0.8;
  pointer-events: none;
}
.progress-bar:hover .progress-thumb,
.progress-bar:active .progress-thumb {
  opacity: 1;
}

.control-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}
.control-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px; min-height: 48px;
  border-radius: 50%;
  transition: all 0.15s;
}
.control-btn:active {
  background: var(--border);
  color: var(--text);
}
.control-btn.active {
  color: var(--primary);
  background: var(--primary-light);
}
.play-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
  transition: all 0.2s ease;
}
.play-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.speed-btn {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 48px;
}
.speed-btn span {
  font-variant-numeric: tabular-nums;
}

/* ===== 倍速弹出层 ===== */
.speed-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 8px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
}
.speed-popup.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.speed-options {
  display: flex;
  gap: 4px;
}
.speed-options button {
  background: none;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.speed-options button:active {
  background: var(--border);
}
.speed-options button.active {
  background: var(--primary);
  color: white;
}

/* ===== 迷你播放条 ===== */
.mini-player {
  position: fixed;
  bottom: var(--safe-bottom);
  left: 12px; right: 12px;
  height: var(--mini-h);
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  padding: 0 12px 0 16px;
  gap: 12px;
  transform: translateY(calc(100% + 12px));
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 100;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.mini-player.show {
  transform: translateY(0);
}
.mini-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}
.mini-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-progress-bar {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.mini-progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s;
  border-radius: 2px;
}
.mini-play-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
  transition: transform 0.15s;
}
.mini-play-btn:active {
  transform: scale(0.92);
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

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