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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #121212;
  color: #e1e1e1;
  min-height: 100vh;
}

.hidden { display: none !important; }

.screen { padding: 20px; max-width: 700px; margin: 0 auto; }

/* Login */
.login-container {
  text-align: center;
  padding-top: 20vh;
}

.login-container h1 {
  font-size: 2rem;
  margin-bottom: 8px;
  color: #fff;
}

.login-container p {
  color: #a0a0a0;
  margin-bottom: 32px;
  font-size: 1.1rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 32px;
  border-radius: 24px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: transform 0.1s, opacity 0.2s;
}

.btn:hover { transform: scale(1.03); }
.btn:active { transform: scale(0.98); }

.btn-spotify {
  background: #1DB954;
  color: #fff;
}

.btn-resume {
  background: #1DB954;
  color: #fff;
  padding: 8px 20px;
  font-size: 0.85rem;
}

.btn-small {
  background: #333;
  color: #ccc;
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 16px;
}

.btn-delete {
  background: none;
  color: #888;
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.btn-delete svg { width: 18px; height: 18px; }
.btn-delete:hover { color: #e74c3c; background: rgba(231, 76, 60, 0.1); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #282828;
}

header h1 {
  font-size: 1.3rem;
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-name {
  color: #a0a0a0;
  font-size: 0.85rem;
}

/* Card */
.card {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.card-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #1DB954;
  margin-bottom: 10px;
}

.np-track {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

.np-artist {
  color: #a0a0a0;
  font-size: 0.9rem;
  margin-top: 2px;
}

.np-playlist {
  color: #666;
  font-size: 0.8rem;
  margin-top: 6px;
}

/* Section */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section h2 {
  font-size: 1.1rem;
  color: #fff;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.search-input {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 9px 14px;
  color: #e1e1e1;
  font-size: 0.85rem;
  outline: none;
}

.search-input:focus { border-color: #1DB954; }
.search-input::placeholder { color: #666; }

.sort-select {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 9px 12px;
  color: #e1e1e1;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
}

.sort-select:focus { border-color: #1DB954; }

/* Bookmarks */
.bookmarks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Swipe-to-delete wrapper */
.bookmark-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
}

.bookmark-delete-bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background: #e74c3c;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 24px;
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  gap: 8px;
}

.bookmark-delete-bg svg { width: 20px; height: 20px; }

.bookmark-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #1a1a1a;
  border-radius: 10px;
  padding: 12px 16px;
  transition: background 0.15s, transform 0.2s ease-out;
  position: relative;
  z-index: 1;
  touch-action: pan-y;
}

.bookmark-card.swiping { transition: none; }
.bookmark-card.removing { transition: transform 0.3s ease-out, opacity 0.3s ease-out; opacity: 0; }
.bookmark-card:hover { background: #222; }

.bookmark-img {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #333;
}

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

.bookmark-playlist-name {
  font-weight: 600;
  color: #fff;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-track {
  color: #a0a0a0;
  font-size: 0.8rem;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-position {
  color: #666;
  font-size: 0.75rem;
  margin-top: 2px;
}

.bookmark-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.empty-state {
  color: #666;
  text-align: center;
  padding: 40px 20px;
  font-size: 0.9rem;
}

/* Error */
.error {
  color: #e74c3c;
  margin-top: 16px;
  font-size: 0.9rem;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1DB954;
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100;
}

.toast.show { opacity: 1; }
.toast.error { background: #e74c3c; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: #1a1a1a;
  border-radius: 10px;
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 10px 16px;
  background: none;
  border: none;
  color: #888;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.tab.active {
  background: #282828;
  color: #fff;
}

.tab:hover:not(.active) { color: #bbb; }

.tab-content { }

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

.playlist-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #1a1a1a;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.playlist-card:hover { background: #222; }
.playlist-card:active { background: #282828; }

.playlist-card-img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #333;
}

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

.playlist-card-name {
  font-weight: 600;
  color: #fff;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-card-count {
  color: #888;
  font-size: 0.8rem;
  margin-top: 2px;
}

.playlist-card-play {
  background: #1DB954;
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, opacity 0.2s;
}

.playlist-card-play:hover { transform: scale(1.1); }
.playlist-card-play:active { transform: scale(0.95); }

/* Track List Header */
.btn-back {
  background: none;
  border: none;
  color: #a0a0a0;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 12px;
  display: block;
}

.btn-back:hover { color: #fff; }

.track-list-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.tl-cover {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  object-fit: cover;
  background: #333;
  flex-shrink: 0;
}

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

.tl-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  word-break: break-word;
}

.tl-count {
  color: #888;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

/* Track List */
.tracks-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.track-row:hover { background: #1a1a1a; }
.track-row:active { background: #222; }
.track-row.is-playing { background: #1a2e1f; }

.track-num {
  color: #888;
  font-size: 0.8rem;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

.track-row.is-playing .track-num { color: #1DB954; }

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

.track-title {
  color: #e1e1e1;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-row.is-playing .track-title { color: #1DB954; }

.track-artist {
  color: #888;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.track-duration {
  color: #888;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* Loading spinner */
.track-loading {
  text-align: center;
  padding: 20px;
  color: #888;
}

/* Playback Bar */
.playback-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #181818;
  border-top: 1px solid #282828;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  z-index: 50;
  max-width: 700px;
  margin: 0 auto;
}

.pb-info {
  flex: 1;
  min-width: 0;
  margin-right: 12px;
}

.pb-track {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-artist {
  color: #888;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.pb-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}

.pb-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }

.pb-btn-main {
  background: #fff;
  color: #121212;
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.pb-btn-main:hover { background: #e0e0e0; color: #121212; }

/* Bottom padding when playback bar is visible */
body.has-playback-bar .screen {
  padding-bottom: 72px;
}

/* Responsive */
@media (max-width: 500px) {
  .screen { padding: 12px; }
  .bookmark-card { padding: 10px 12px; gap: 10px; }
  .bookmark-img { width: 44px; height: 44px; }
  header { flex-direction: column; gap: 8px; align-items: flex-start; }
  .tl-cover { width: 80px; height: 80px; }
  .tl-name { font-size: 1rem; }
  .track-list-header { gap: 12px; }
  .playback-bar { padding: 8px 12px; }
}
