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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', -apple-system, sans-serif;
  padding: 1rem;
  transition: background-color 0.3s, color 0.3s;
}

button { font-family: inherit; border: none; cursor: pointer; background: none; color: inherit; }
input { font-family: inherit; }

body {
  background: var(--bg-page, #1a1a2e);
  color: var(--text, #e0e0e0);
}

/* ==================== PLAYER CARD ==================== */

.player {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 32px var(--shadow);
  transition: background-color 0.3s;
}

.player-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.player-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.player-title {
  font-size: 1.25rem;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.player-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
  display: none;
}

.player-subtitle.visible {
  display: block;
}

.player-header .icon-btn {
  font-size: 1.2rem;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-header .icon-btn:hover {
  color: var(--text);
  background: var(--bg-accent-area);
}

/* ==================== NOW PLAYING ==================== */

.now-playing {
  text-align: center;
  margin-bottom: 1.2rem;
  min-height: 3rem;
}

.now-playing .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.now-playing .song-name {
  font-size: 0.95rem;
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
  font-weight: 500;
}

/* ==================== PROGRESS BAR ==================== */

.progress-container {
  background: var(--bg-accent-area);
  border-radius: 4px;
  height: 6px;
  cursor: pointer;
  margin-bottom: 0.3rem;
  position: relative;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  pointer-events: none;
}

.progress-input {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: -8px;
  left: 0;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
  padding: 0;
  z-index: 2;
}

.progress-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.progress-container:hover .progress-input::-webkit-slider-thumb {
  opacity: 1;
}

.progress-input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.progress-container:hover .progress-input::-moz-range-thumb {
  opacity: 1;
}

.progress-input::-webkit-slider-runnable-track {
  background: transparent;
}

.progress-input::-moz-range-track {
  background: transparent;
}

.time-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}

/* ==================== CONTROLS ==================== */

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

.ctrl-btn {
  background: var(--bg-accent-area);
  color: var(--accent);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s, color 0.2s;
}

.ctrl-btn:hover { background: var(--accent); color: var(--bg-card); }
.ctrl-btn:active { transform: scale(0.93); }

.ctrl-btn.small {
  width: 34px;
  height: 34px;
  font-size: 0.85rem;
}

.ctrl-btn.small.active {
  color: var(--bg-card);
  background: var(--accent);
}

.play-btn {
  width: 52px;
  height: 52px;
  font-size: 1.1rem;
}

/* ==================== VOLUME ==================== */

.volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1.2rem;
  padding: 0 0.5rem;
}

.volume-row .icon-btn {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.volume-row .icon-btn:hover {
  color: var(--text);
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-accent-area);
  outline: none;
  cursor: pointer;
}

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

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

/* ==================== TABS ==================== */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.6rem;
}

.tab {
  flex: 1;
  padding: 8px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  text-align: center;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-dd-wrap { position: relative; flex: 1; display: flex; }
.tab-dd-wrap .tab { flex: 1; }

.tab-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 220px;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  z-index: 50;
  box-shadow: 0 4px 16px var(--shadow);
  margin-top: 4px;
}

.tab-dropdown.open { display: block; }

.dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text);
  text-align: left;
  transition: background 0.1s;
}

.dd-item:hover { background: var(--bg-accent-area); }
.dd-item .icon-btn { opacity: 0; font-size: 14px; }
.dd-item:hover .icon-btn { opacity: 1; }

.dd-new {
  color: var(--accent);
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

#ddPlaylistList:empty + .dd-new { border-top: none; margin-top: 0; }

/* ==================== SEARCH ==================== */

.search-row {
  margin-bottom: 0.5rem;
}

.search-input {
  width: 100%;
  padding: 7px 12px;
  background: var(--bg-accent-area);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input::placeholder { color: var(--text-dim); }
.search-input:focus { border-color: var(--accent); }

/* ==================== PLAYLIST / SONG LIST ==================== */

.playlist-list {
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
}

.playlist-list::-webkit-scrollbar { width: 4px; }
.playlist-list::-webkit-scrollbar-thumb { background: var(--bg-accent-area); border-radius: 4px; }

.song-item {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.song-item:hover { background: var(--bg-accent-area); color: var(--text); }
.song-item.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 600; }

.song-item.unavailable {
  opacity: 0.35;
  cursor: not-allowed;
}

.song-item.unavailable:hover { background: transparent; color: var(--text-secondary); }

.song-item .idx {
  color: var(--text-dim);
  font-size: 0.72rem;
  min-width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}

.song-item.active .idx { color: var(--accent); }

.song-item .name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.song-item .badge-na {
  font-size: 0.6rem;
  background: var(--bg-accent-area);
  color: var(--text-dim);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  flex-shrink: 0;
}

.badge-seeded {
  font-size: 0.65rem;
  opacity: 0.6;
  margin-left: 2px;
}

.song-item .fav-btn {
  font-size: 0.85rem;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.song-item .fav-btn:hover { color: var(--text); }
.song-item .fav-btn.on { color: var(--heart); }

.song-item .menu-btn {
  font-size: 0.9rem;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.1s;
}

.song-item:hover .menu-btn { opacity: 1; }
.song-item .menu-btn:hover { color: var(--text); background: var(--bg-accent-area); }

.song-item .recent-time {
  font-size: 0.62rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.empty-msg {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.empty-msg .empty-icon {
  font-size: 2rem;
  opacity: 0.2;
  display: block;
  margin-bottom: 0.5rem;
}

/* ==================== ERROR ==================== */

.error {
  color: #e07070;
  font-size: 0.78rem;
  text-align: center;
  margin-top: 0.6rem;
  min-height: 1rem;
}

/* ==================== MODALS ==================== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--modal-bg);
  border-radius: 12px;
  width: 380px;
  max-width: calc(100vw - 2rem);
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px var(--shadow);
}

.modal-sm { width: 300px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 0.9rem; font-weight: 700; }

.modal-close { font-size: 1.2rem; color: var(--text-secondary); }
.modal-close:hover { color: var(--text); }

.modal-body { padding: 16px; overflow-y: auto; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

/* ==================== SETTINGS ==================== */

.s-section { margin-bottom: 18px; }
.s-section:last-child { margin-bottom: 0; }

.s-section h4 {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.theme-options { display: flex; gap: 6px; }

.theme-card {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  transition: border-color 0.2s, color 0.2s;
}

.theme-card:hover { border-color: var(--text-secondary); }
.theme-card.active { border-color: var(--accent); color: var(--text); }

.theme-dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }

.mode-toggle { display: flex; gap: 6px; }

.mode-btn {
  flex: 1;
  padding: 7px;
  border-radius: 8px;
  border: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.78rem;
  transition: border-color 0.2s, color 0.2s;
}

.mode-btn:hover { border-color: var(--text-secondary); }
.mode-btn.active { border-color: var(--accent); color: var(--text); }

.data-btns { display: flex; gap: 6px; }
.hint { margin-top: 5px; font-size: 0.65rem; color: var(--text-dim); }

/* ==================== BUTTONS & FORMS ==================== */

.btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg-accent-area);
  color: var(--text);
  transition: background 0.15s;
}

.btn:hover { background: var(--border); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: #DC3545; color: #fff; }
.btn-danger:hover { background: #C82333; }
.btn-link { background: none; color: var(--accent); padding: 5px 0; font-size: 0.78rem; }
.btn-link:hover { text-decoration: underline; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-accent-area);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  font-size: 0.85rem;
  transition: border-color 0.2s;
}

.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-dim); }

/* ==================== PLAYLIST CHECKBOXES ==================== */

#playlistCheckboxes {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.pl-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s;
}

.pl-check:hover { background: var(--bg-accent-area); }
.pl-check input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

/* ==================== CONTEXT MENU ==================== */

.context-menu {
  display: none;
  position: fixed;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 160px;
  z-index: 300;
  box-shadow: 0 4px 16px var(--shadow);
}

.context-menu.open { display: block; }

.ctx-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--text);
  text-align: left;
  transition: background 0.1s;
}

.ctx-item:hover { background: var(--bg-accent-area); }
.ctx-item.danger { color: #DC3545; }

/* ==================== MOBILE ==================== */

@media (max-width: 480px) {
  .player { padding: 1.5rem 1rem; }
  .controls { gap: 0.6rem; }
}
