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

:root {
  --bg: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a26;
  --text: #e8e8f0;
  --text-secondary: #8888a0;
  --accent: #f5c542;
  --accent-hover: #ffd966;
  --danger: #e74c3c;
  --border: rgba(255,255,255,0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --player-height: 64px;
  --tab-height: 56px;
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--player-height) + var(--tab-height) + var(--safe-bottom) + 8px);
  overscroll-behavior-y: contain;
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10,10,15,0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.logo-icon { font-size: 24px; }
.logo-text { font-size: 18px; font-weight: 700; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  max-width: 280px;
  width: 100%;
  transition: border-color 0.2s;
}

.search-box:focus-within { border-color: var(--accent); }

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  min-width: 0;
}

.search-box input::placeholder { color: var(--text-secondary); }
.search-box svg { color: var(--text-secondary); flex-shrink: 0; }

.search-clear {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}

/* ── Tab Bar ── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(12,12,18,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 90;
  transition: transform 0.25s;
}

body.has-player .tab-bar {
  transform: translateY(calc(-1 * var(--player-height)));
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: 12px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tab span { white-space: nowrap; }
.tab.active { color: var(--accent); }
.tab svg { opacity: 0.6; }
.tab.active svg { opacity: 1; }

.record-tab-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(231,76,60,0.35);
  margin-top: -8px;
}

/* ── Main ── */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.page-header h1 { font-size: 22px; font-weight: 700; }

.badge {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
}

.page-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-top-bar h2 { font-size: 18px; font-weight: 600; }
.page-top-bar .spacer { width: 60px; }

/* ── Song List ── */
.song-list { display: flex; flex-direction: column; gap: 2px; }

.song-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.song-item:active { background: var(--bg-tertiary); }
.song-item.playing { background: var(--bg-secondary); }

.song-cover-sm {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

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

.song-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-artist {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-item.playing .song-title { color: var(--accent); }

.song-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.song-play-count {
  font-size: 11px;
  color: var(--text-secondary);
  margin-right: 4px;
}

.song-delete-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 6px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}

.song-item:hover .song-delete-btn,
.song-item:active .song-delete-btn { opacity: 1; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; margin-bottom: 6px; }
.empty-hint { font-size: 13px; color: var(--text-secondary); opacity: 0.7; }

.empty-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 20px;
  padding: 10px 24px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:active { transform: scale(0.96); }

.btn-outline {
  background: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  border: 1.5px solid var(--accent);
  border-radius: 20px;
  padding: 10px 24px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-outline:active { transform: scale(0.96); }

.btn-primary-sm {
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: 13px;
  border: none;
  border-radius: 16px;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 24px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
  padding: 8px 0;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 18px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-play-main {
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: 15px;
  border: none;
  border-radius: 20px;
  padding: 10px 28px;
  cursor: pointer;
  margin-top: 12px;
  -webkit-tap-highlight-color: transparent;
}

.btn-play-main:active { transform: scale(0.96); }

.btn-danger-sm {
  background: none;
  color: var(--text-secondary);
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 18px;
  cursor: pointer;
  margin-top: 12px;
}

/* ── Upload ── */
.upload-container { max-width: 500px; margin: 0 auto; }

.upload-drop-zone {
  border: 2px dashed rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.upload-drop-zone:active,
.upload-drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(245,197,66,0.03);
}

.drop-icon { font-size: 40px; margin-bottom: 10px; }
.drop-zone p { font-size: 15px; margin-bottom: 6px; color: var(--text); }
.drop-hint { font-size: 12px; color: var(--text-secondary); }

.upload-form { margin-top: 20px; }

.selected-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}

.file-icon { font-size: 20px; }
#selectedFileName { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.form-row { margin-bottom: 16px; }

.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-row input[type="text"] {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-row input[type="text"]:focus { border-color: var(--accent); }

.color-picker { display: flex; gap: 10px; flex-wrap: wrap; }

.color-option {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.color-option:active { transform: scale(0.9); }
.color-option.active { border-color: #fff; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #fff; }

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

.upload-progress { margin-top: 16px; }

.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s;
}

.upload-progress span, #saveProgressText { font-size: 12px; color: var(--text-secondary); }

/* ── Record ── */
.record-container { max-width: 500px; margin: 0 auto; }

.waveform-container {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.waveform-canvas {
  width: 100%;
  height: 100px;
  display: block;
}

.record-timer {
  position: absolute;
  bottom: 8px;
  right: 14px;
  font-size: 14px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.record-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.rec-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(231,76,60,0.4);
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.rec-btn:active { transform: scale(0.92); }

.rec-btn-inner {
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.2s;
}

.rec-btn.recording .rec-btn-inner {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.rec-btn.recording {
  animation: rec-pulse 1.5s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(231,76,60,0.4); }
  50% { box-shadow: 0 4px 30px rgba(231,76,60,0.7); }
}

.rec-hint {
  font-size: 13px;
  color: var(--text-secondary);
}

.rec-support-hint {
  font-size: 12px;
  margin-top: 4px;
}

/* ── Record Preview ── */
.record-preview {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.record-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 600;
}

.record-duration { color: var(--text-secondary); font-size: 13px; font-weight: 400; }

.record-preview-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-progress {
  flex: 1;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  cursor: pointer;
  overflow: hidden;
}

.preview-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
}

.preview-time {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ── Detail ── */
.detail-header {
  display: flex;
  gap: 20px;
  margin-bottom: 32px;
}

.detail-cover {
  width: 180px;
  height: 180px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.cover-icon { font-size: 56px; }

.detail-info { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.detail-info h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; word-break: break-word; }
.detail-info p { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }

.detail-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Comments ── */
.comments-section { max-width: 100%; }
.comments-section h3 { font-size: 18px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

.comment-form {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.comment-form input,
.comment-form textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  margin-bottom: 10px;
  resize: vertical;
  font-family: inherit;
  -webkit-appearance: none;
}

.comment-form input:focus, .comment-form textarea:focus { border-color: var(--accent); }

.comment-list { display: flex; flex-direction: column; gap: 10px; }

.comment-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.comment-nickname { font-weight: 600; font-size: 13px; color: var(--accent); }
.comment-time { font-size: 11px; color: var(--text-secondary); }
.comment-text { font-size: 14px; line-height: 1.6; }

.comment-del {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── Player Bar ── */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  transform: translateY(0);
}

.player-bar.has-player {
  bottom: calc(var(--tab-height) + var(--safe-bottom));
}

.player-progress-bar {
  height: 3px;
  background: rgba(255,255,255,0.08);
  cursor: pointer;
  padding: 6px 0;
  margin: -6px 0;
}

.player-progress-fill {
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
}

.player-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--player-height);
  padding: 0 12px;
  background: rgba(18,18,26,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}

.player-song-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 4px;
  margin: -4px;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.player-cover {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.player-meta { min-width: 0; }
.player-title { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { display: block; font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: all 0.1s;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.play-btn {
  font-size: 20px;
  background: var(--accent);
  color: #000;
  width: 40px;
  height: 40px;
}

.player-time {
  font-size: 11px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.player-volume {
  display: none;
  align-items: center;
  gap: 6px;
}

.volume-btn { display: none; }

.volume-slider {
  width: 70px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  outline: none;
}

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

/* ── Toast ── */
.toast {
  position: fixed;
  top: calc(60px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: var(--bg-tertiary);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 200;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Desktop (768+) ── */
@media (min-width: 768px) {
  body { padding-bottom: calc(var(--player-height) + 16px); }

  .tab-bar { display: none; }

  body.has-player .tab-bar { transform: none; }

  .player-bar { bottom: 0; }
  .player-bar.has-player { bottom: 0; }

  main { padding: 28px 32px; }

  header { padding: 14px 32px; }

  .search-box { max-width: 360px; padding: 10px 18px; }

  .page-header h1 { font-size: 28px; }

  .empty-state { padding: 80px 20px; }
  .empty-icon { font-size: 64px; }

  .detail-header { gap: 28px; }
  .detail-cover { width: 220px; height: 220px; }
  .cover-icon { font-size: 72px; }
  .detail-info h2 { font-size: 32px; }

  .player-volume { display: flex; }
  .volume-btn { display: flex; }

  .player-time { display: flex; }

  .player-inner { height: 72px; gap: 20px; padding: 0 24px; }
  :root { --player-height: 72px; }

  .song-delete-btn { opacity: 0; }
  .song-item:hover .song-delete-btn { opacity: 1; }
}

/* ── Small phones (< 360px) ── */
@media (max-width: 360px) {
  .logo-text { display: none; }
  .player-time { display: none; }
}
