:root {
  --bg: #09090b;
  --surface: #151014;
  --surface-2: #1e161d;
  --surface-3: #2a1f28;
  --border: rgba(249, 168, 212, 0.16);
  --text: #fff5fa;
  --muted: #c4a7b7;
  --pink: #f9a8d4;
  --pink-soft: rgba(249, 168, 212, 0.2);
  --pink-strong: #fbcfe8;
  --danger: #fb7185;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100%;
  overflow: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
}

.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
  flex-shrink: 0;
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.status-dot.online {
  background: var(--pink);
  box-shadow: 0 0 10px rgba(249, 168, 212, 0.7);
}

.brand {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.3px;
  color: var(--pink-strong);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active {
  color: var(--text);
  background: var(--surface-2);
}
.danger-ico {
  color: var(--danger);
}

.add-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--pink);
  color: #09090b;
  border: none;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px calc(76px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}
.content.has-mini {
  padding-bottom: calc(140px + var(--safe-bottom));
}

.page-wrap {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.view {
  display: none;
}
.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.text-btn {
  background: none;
  border: none;
  color: var(--pink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
}

/* Segmented switch */
.seg-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin: 6px 0 10px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--pink);
  color: #09090b;
}

/* Horizontal recent cards */
.cards-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.cards-row::-webkit-scrollbar {
  display: none;
}

.card-tile {
  width: 118px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
}
.card-tile img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-2);
  display: block;
}
.card-tile-title {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-tile-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Swipeable Track rows */
.track-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.track-swipe-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--pink);
}

.track-swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 16px;
  color: #09090b;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
}

.track-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid rgba(249, 168, 212, 0.08);
  cursor: pointer;
  transition: transform 0.16s ease-out;
  touch-action: pan-y;
}
.track-row.swiping {
  transition: none;
}
.track-row.playing {
  background: #231520;
  border-color: rgba(249, 168, 212, 0.35);
}
.track-row.playing .track-title {
  color: var(--pink-strong);
}

.track-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: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.offline-tag {
  color: var(--pink);
  font-weight: 600;
}

.more-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.more-btn:active {
  background: var(--surface-2);
  color: var(--pink);
}

/* Playlists */
.playlists-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.playlist-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}
.playlist-ico {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--pink-soft);
  color: var(--pink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.playlist-meta {
  flex: 1;
  min-width: 0;
}
.playlist-name {
  font-size: 14px;
  font-weight: 700;
}
.playlist-count {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.pl-detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}
.pl-detail-meta {
  flex: 1;
  min-width: 0;
}
.pl-detail-meta h2 {
  margin: 0;
  font-size: 18px;
}
.pl-detail-meta span {
  font-size: 12px;
  color: var(--muted);
}
.pl-detail-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.btn-pink-sm {
  flex: 1;
  padding: 10px;
  border-radius: 999px;
  border: none;
  background: var(--pink);
  color: #09090b;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost-sm {
  flex: 1;
  padding: 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--pink);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* Search */
.search-wrap {
  position: relative;
  margin: 6px 0 4px;
}
.search-ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

/* Offline banner */
.offline-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(249, 168, 212, 0.16) 0%, var(--surface) 100%);
  border: 1px solid rgba(249, 168, 212, 0.24);
  padding: 14px;
  border-radius: 14px;
  margin: 6px 0 12px;
}
.offline-banner h3 {
  margin: 0 0 4px;
  font-size: 15px;
}
.offline-banner p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.play-circle-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--pink);
  color: #09090b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Mini Player */
.mini-player {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 20px);
  max-width: 700px;
  bottom: calc(58px + var(--safe-bottom));
  background: linear-gradient(135deg, #241621 0%, #151014 100%);
  border: 1px solid rgba(249, 168, 212, 0.32);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  z-index: 20;
}

.mini-progress-track {
  height: 3px;
  background: rgba(249, 168, 212, 0.15);
}
.mini-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--pink);
}

.mini-body {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.mini-cover {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-3);
}
.mini-meta {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.mini-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-artist {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 0 calc(6px + var(--safe-bottom));
  background: rgba(9, 9, 11, 0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  z-index: 25;
}
.nav-item {
  flex: 1;
  max-width: 240px;
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  padding: 2px 0;
  cursor: pointer;
}
.nav-item.active {
  color: var(--pink);
}

/* Full Screen Player */
.full-player {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #341929 0%, #180e15 45%, #09090b 100%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 22px calc(22px + var(--safe-bottom));
}

.full-header,
.full-info,
.full-seek,
.full-controls {
  max-width: 460px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.full-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.full-label {
  font-size: 11px;
  letter-spacing: 1.2px;
  font-weight: 700;
  color: var(--muted);
}

.full-art-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 8px 0;
}
.full-cover {
  width: min(76vw, 310px);
  height: min(76vw, 310px);
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 20px 52px rgba(249, 168, 212, 0.22);
  border: 1px solid rgba(249, 168, 212, 0.22);
  background: var(--surface-2);
}

.full-title {
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.full-artist {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.full-seek input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}
.full-seek input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--pink);
  border: none;
  cursor: pointer;
}
.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

.full-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px;
}
.ctrl-sec {
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ctrl-sec.active {
  color: var(--pink);
}
.ctrl-main {
  background: none;
  border: none;
  color: var(--text);
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ctrl-play {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--pink);
  color: #09090b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Action Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(18px + var(--safe-bottom));
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.sheet-head img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
}
.sheet-meta {
  min-width: 0;
}
.sheet-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-sub {
  font-size: 12px;
  color: var(--muted);
}
.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.sheet-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 8px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
}
.sheet-btn:active {
  background: var(--surface-2);
}
.sheet-btn.danger {
  color: var(--danger);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 {
  margin: 0;
  font-size: 16px;
}
.modal-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0 14px;
}
.modal-card input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.add-status {
  min-height: 20px;
  margin: 10px 0;
  font-size: 13px;
  color: var(--pink);
}
.btn-pink-full {
  width: 100%;
  padding: 12px;
  border-radius: 999px;
  border: none;
  background: var(--pink);
  color: #09090b;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.btn-pink-full:disabled {
  opacity: 0.55;
}

.pl-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  max-height: 50vh;
  overflow-y: auto;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(130px + var(--safe-bottom));
  background: var(--pink);
  color: #09090b;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  z-index: 80;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.empty-note {
  color: var(--muted);
  font-size: 13px;
  padding: 14px 0;
}
