:root {
  --bg: #0b0b0f;
  --surface: #15151d;
  --surface-2: #1f1f2b;
  --text: #f4f4f8;
  --muted: #9898ad;
  --accent: #1db954;
  --danger: #ff5566;
  --border: #262636;
  --player-height: 132px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--player-height) + env(safe-area-inset-bottom));
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 11, 15, 0.94);
  backdrop-filter: blur(12px);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

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

.header-row h1 {
  font-size: 1.3rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #06140b;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger-text {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.85rem;
  cursor: pointer;
}

.search-box input, .online-search-form input, .piped-settings input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
}

.search-box input:focus, .online-search-form input:focus, .piped-settings input:focus {
  border-color: var(--accent);
}

.source-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.online-search-form {
  display: flex;
  gap: 8px;
}

.piped-settings {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.piped-settings summary {
  cursor: pointer;
  margin-bottom: 6px;
}

.playlist-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 10px;
  scrollbar-width: none;
}

.playlist-bar::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}

.chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 10px 12px 24px;
}

.status-banner {
  background: var(--surface-2);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 10px;
  line-height: 1.35;
}

.status-banner.error {
  color: var(--danger);
  border: 1px solid rgba(255, 85, 102, 0.35);
}

.playlist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.track-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid transparent;
  cursor: pointer;
}

.track-item.active {
  border-color: var(--accent);
  background: #14221a;
}

.track-item .cover {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

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

.track-title {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.track-duration {
  font-size: 0.78rem;
  color: var(--muted);
  flex-shrink: 0;
}

.track-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.mini-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
}

.mini-btn:active {
  background: var(--surface-2);
}

.dl-btn {
  background: var(--accent);
  color: #06140b;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.dl-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 50px 20px;
}

.empty-state .sub {
  margin-top: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: #12121a;
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#seek-bar {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.player-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.now-playing .cover {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

.track-meta {
  min-width: 0;
  flex: 1;
}

.controls {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.25rem;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.icon-btn.active {
  color: var(--accent);
}

.play-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #06140b;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  font-size: 0.95rem;
}

.playlist-modal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.playlist-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.hidden {
  display: none !important;
}
