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

:root {
  --green:       #1DB954;
  --green-hover: #1ed760;
  --bg:          #121212;
  --surface:     #181818;
  --surface-2:   #282828;
  --border:      #2a2a2a;
  --text:        #ffffff;
  --muted:       #b3b3b3;
  --dim:         #6b6b6b;
  --radius:      8px;
  --radius-pill: 500px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
.hidden { display: none !important; }

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2.5rem 1.5rem;
  text-align: center;
  max-width: 420px;
  margin: 0 auto;
}

.logo { margin-bottom: 1.75rem; }

.login-container h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 2rem;
  max-width: 320px;
  line-height: 1.65;
}

.note { font-size: 11px; color: var(--dim); margin-top: 1rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-pill);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.btn-sm { padding: 0.45rem 0.9rem; font-size: 13px; }

.btn-spotify { background: var(--green); color: #000; }
.btn-spotify:hover { background: var(--green-hover); transform: scale(1.02); }

.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: #555; }

header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: rgba(18, 18, 18, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 0.55rem; }
.app-title { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.header-right { display: flex; align-items: center; gap: 0.65rem; }
.username { color: var(--muted); font-size: 13px; }

main { padding: 1.25rem 1.25rem 110px; }

.toolbar {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: #555; }
.search-input::placeholder { color: var(--dim); }
.toolbar-actions { display: flex; gap: 0.45rem; }

.playlists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.9rem;
}

.playlist-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.7rem;
  cursor: pointer;
  user-select: none;
  border: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.playlist-card:hover { background: var(--surface-2); }
.playlist-card.selected { border-color: var(--green); background: rgba(29, 185, 84, 0.07); }

.playlist-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 0.6rem;
  background: var(--surface-2);
}
.playlist-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-img { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; color: var(--dim); }

.check-overlay {
  position: absolute;
  inset: 0;
  background: rgba(29, 185, 84, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.playlist-card.selected .check-overlay { opacity: 1; }
.checkmark { font-size: 2.4rem; color: #fff; font-weight: 700; line-height: 1; }

.playlist-info { min-width: 0; }
.playlist-name { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.playlist-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.loading-spinner { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 0.9rem; padding: 3.5rem 1rem; color: var(--muted); }

.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--green); border-radius: 50%; animation: spin 0.75s linear infinite; flex-shrink: 0; }
.spinner.large { width: 44px; height: 44px; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { grid-column: 1 / -1; text-align: center; padding: 3.5rem 1rem; color: var(--muted); font-size: 13px; }

.action-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
}
.action-bar-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.selected-count { font-weight: 700; font-size: 14px; }
.track-count { font-size: 12px; color: var(--muted); }
.action-bar-right { display: flex; gap: 0.55rem; flex-shrink: 0; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}
.modal { background: var(--surface-2); border-radius: 12px; padding: 1.75rem; width: 100%; max-width: 380px; box-shadow: 0 8px 48px rgba(0,0,0,0.6); }
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.45rem; }
.modal p { color: var(--muted); font-size: 13px; margin-bottom: 1rem; }

.text-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 1.25rem;
}
.text-input:focus { border-color: var(--green); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.65rem; }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(18, 18, 18, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.loading-content { display: flex; flex-direction: column; align-items: center; gap: 1rem; color: var(--muted); text-align: center; padding: 1.5rem; }
.loading-content p { font-size: 15px; font-weight: 500; }
.loading-sub { font-size: 12px !important; font-weight: 400 !important; color: var(--dim); }

.toast {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 0.9rem 1.25rem;
  max-width: min(420px, calc(100vw - 2rem));
  width: max-content;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 6px 32px rgba(0,0,0,0.55);
  animation: slideUp 0.2s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid #e05252; }
.toast a { color: var(--green); text-decoration: none; font-weight: 600; }
.toast a:hover { text-decoration: underline; }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 380px) {
  .playlists-grid { grid-template-columns: repeat(2, 1fr); }
  .action-bar { flex-direction: column; align-items: flex-start; }
  .action-bar-right { width: 100%; }
  .action-bar-right .btn { flex: 1; justify-content: center; }
}
