@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=Playfair+Display:wght@600;700&display=swap');

:root {
  --terracotta: #00E5FF;
  --charcoal: #651FFF;
  --sage: #FF1744;
  --sand: #76FF03;
  --cream: #121212;
  --terracotta-light: #e8947d;
  --terracotta-dark: #c96a50;
  --charcoal-light: #565a7a;
  --charcoal-dark: #2e3048;
  --sage-light: #9cc4af;
  --sage-dark: #6a9a82;
  --sand-light: #f5d9a8;
  --cream-dark: #ece8d2;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(61, 64, 91, 0.08);
  --shadow-md: 0 4px 12px rgba(61, 64, 91, 0.1);
  --shadow-lg: 0 8px 24px rgba(61, 64, 91, 0.14);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

::selection {
  background: var(--terracotta);
  color: var(--white);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--charcoal);
  min-height: 100vh;
  line-height: 1.6;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--charcoal);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.header-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.75rem;
  animation: bounce 2s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.app-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cream);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.app-subtitle {
  font-size: 0.8rem;
  color: var(--sage-light);
  font-weight: 400;
  opacity: 0.85;
}

.add-song-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--terracotta);
  color: var(--white);
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.add-song-btn:hover {
  background: var(--terracotta-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(224, 122, 95, 0.35);
}

.add-song-btn:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Main Content */
.main-content {
  flex: 1;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Playlist */
.playlist-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.playlist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.25rem 0.5rem;
}

.song-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--charcoal);
}

.sort-label {
  font-size: 0.78rem;
  color: var(--charcoal-light);
  opacity: 0.7;
}

.songs-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Song Card */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.song-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--cream-dark);
  overflow: hidden;
  transition: all 0.2s ease;
  animation: fadeInUp 0.4s ease both;
}

.song-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--sand);
}

.song-card-voted {
  border-left: 3px solid var(--terracotta);
}

.song-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  cursor: pointer;
}

.song-rank {
  flex-shrink: 0;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rank-display {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--charcoal-light);
  opacity: 0.6;
}

.rank-medal {
  font-size: 1.4rem;
  opacity: 1;
}

.song-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.song-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--charcoal-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.song-artist {
  font-size: 0.85rem;
  color: var(--charcoal-light);
  font-weight: 400;
}

.song-link {
  font-size: 0.78rem;
  color: var(--sage-dark);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.song-link:hover {
  color: var(--sage);
  text-decoration: underline;
}

.youtube-badge {
  font-size: 0.75rem;
  color: var(--terracotta);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.added-by {
  font-size: 0.72rem;
  color: var(--charcoal-light);
  opacity: 0.5;
  margin-top: 0.15rem;
}

.song-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Vote Button */
.vote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  background: var(--cream);
  border: 1.5px solid var(--cream-dark);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}

.vote-btn:hover {
  border-color: var(--terracotta-light);
  background: #fdf2ee;
}

.vote-btn-active {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--white);
}

.vote-btn-active:hover {
  background: var(--terracotta-dark);
  border-color: var(--terracotta-dark);
}

.vote-arrow {
  font-size: 0.9rem;
  line-height: 1;
}

.vote-count {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.vote-btn-active .vote-arrow,
.vote-btn-active .vote-count {
  color: var(--white);
}

/* Remove Button */
.remove-btn {
  background: transparent;
  border: 1.5px solid transparent;
  color: var(--charcoal-light);
  opacity: 0.35;
  font-size: 1.1rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.remove-btn:hover {
  opacity: 0.7;
  background: #fef2f2;
  color: #dc2626;
}

.remove-btn-confirm {
  opacity: 1;
  background: #dc2626;
  color: var(--white);
  border-color: #dc2626;
}

.remove-btn-confirm:hover {
  background: #b91c1c;
}

/* YouTube Embed */
.youtube-embed {
  padding: 0 1rem 1rem;
  animation: fadeInUp 0.3s ease both;
}

.embed-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--charcoal-dark);
}

.embed-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Skeleton Loading */
.skeleton-container {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.5rem 0;
}

.skeleton-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.skeleton-line {
  border-radius: 4px;
  background: linear-gradient(90deg, var(--cream-dark) 25%, var(--cream) 50%, var(--cream-dark) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-title {
  width: 65%;
  height: 18px;
}

.skeleton-artist {
  width: 40%;
  height: 14px;
}

.skeleton-link {
  width: 25%;
  height: 12px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  animation: bounce 2s ease infinite;
}

.empty-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 0.5rem;
}

.empty-text {
  font-size: 0.95rem;
  color: var(--charcoal-light);
  opacity: 0.7;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61, 64, 91, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--cream-dark);
  background: var(--cream);
}

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--charcoal-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--charcoal-light);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--cream-dark);
  color: var(--charcoal);
}

/* Form */
.add-song-form {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-error {
  background: #fef2f2;
  color: #dc2626;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  border-left: 3px solid #dc2626;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--charcoal);
}

.form-input {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--charcoal);
  transition: all 0.2s ease;
  min-height: 44px;
}

.form-input::placeholder {
  color: var(--charcoal-light);
  opacity: 0.45;
}

.form-input:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.15);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--charcoal-light);
  opacity: 0.6;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding-top: 0.5rem;
}

.btn-cancel {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 1.2rem;
  border: 1.5px solid var(--cream-dark);
  background: var(--white);
  color: var(--charcoal);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}

.btn-cancel:hover {
  background: var(--cream);
}

.btn-submit {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.5rem;
  border: none;
  background: var(--terracotta);
  color: var(--white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.btn-submit:hover {
  background: var(--terracotta-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(224, 122, 95, 0.3);
}

.btn-submit:active {
  transform: translateY(0);
}

.btn-submit:disabled,
.btn-cancel:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Responsive */
@media (max-width: 640px) {
  .header-content {
    padding: 1rem;
  }

  .app-title {
    font-size: 1.2rem;
  }

  .app-subtitle {
    font-size: 0.72rem;
  }

  .add-song-btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.82rem;
  }

  .main-content {
    padding: 1rem;
  }

  .song-main {
    padding: 0.85rem;
    gap: 0.5rem;
  }

  .song-rank {
    width: 32px;
  }

  .song-title {
    font-size: 0.95rem;
  }

  .modal-content {
    max-width: 100%;
    border-radius: var(--radius-md);
  }

  .add-song-form {
    padding: 1.25rem;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .btn-cancel,
  .btn-submit {
    width: 100%;
    text-align: center;
  }
}

<!-- WALKTHROUGH_SCRIPT:
[
  {"step": 1, "narration": "Welcome to Collab Playlist! This is where everyone can add songs and vote to decide the playlist order.", "view": "default", "highlight_selector": ".app-header", "wait_for": "tap_to_continue"},
  {"step": 2, "narration": "Tap the '+ Add Song' button to contribute a track to the playlist.", "view": "default", "highlight_selector": ".add-song-btn", "wait_for": "user_interaction"},
  {"step": 3, "narration": "Fill in the song title, artist, and optionally a YouTube link for an embedded preview.", "view": "default", "highlight_selector": ".add-song-form", "wait_for": "user_interaction"},
  {"step": 4, "narration": "Each song card shows the title, artist, and a vote button. Tap the up arrow to upvote a song.", "view": "default", "highlight_selector": ".vote-btn", "wait_for": "user_interaction"},
  {"step": 5, "narration": "Songs with YouTube links can be previewed inline — just tap the card to expand the video player.", "view": "default", "highlight_selector": ".youtube-badge", "wait_for": "tap_to_continue"},
  {"step": 6, "narration": "The playlist automatically sorts by votes so the most popular songs rise to the top. Enjoy!", "view": "default", "highlight_selector": ".playlist-container", "wait_for": "tap_to_continue"}
]
-->

.vote-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.vote-btn[disabled]:hover {
  transform: none;
  box-shadow: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(244, 241, 222, 0.1);
  color: var(--cream);
  border: 1px solid rgba(244, 241, 222, 0.18);
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16);
  flex-shrink: 0;
}

.presence-text {
  line-height: 1;
}

.presence-panel {
  background: var(--white);
  border: 1px solid var(--cream-dark);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1rem 0.9rem;
  margin-bottom: 1rem;
}

.presence-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.presence-panel-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--charcoal-dark);
}

.presence-panel-count {
  font-size: 0.8rem;
  color: var(--charcoal-light);
}

.presence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.presence-user {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--cream);
  border: 1px solid var(--cream-dark);
  border-radius: 999px;
  padding: 0.4rem 0.7rem 0.4rem 0.4rem;
}

.presence-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--terracotta);
  color: var(--white);
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.presence-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--charcoal);
}

.presence-empty {
  font-size: 0.9rem;
  color: var(--charcoal-light);
  opacity: 0.75;
  padding: 0.25rem 0;
}

@media (max-width: 640px) {
  .header-actions {
    gap: 0.5rem;
  }

  .presence-chip {
    font-size: 0.72rem;
    padding: 0.38rem 0.6rem;
  }

  .presence-panel {
    padding: 0.9rem;
  }

  .presence-panel-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

.reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--cream-dark);
  background: var(--cream);
  color: var(--charcoal);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 30px;
}

.reaction-btn:hover {
  background: #f8f4ea;
  border-color: var(--sand);
  transform: translateY(-1px);
}

.reaction-btn-active {
  background: var(--charcoal);
  border-color: var(--charcoal);
  color: var(--white);
}

.reaction-btn-active:hover {
  background: var(--charcoal-dark);
  border-color: var(--charcoal-dark);
}

.reaction-fire.reaction-btn-active {
  background: #ef4444;
  border-color: #ef4444;
}

.reaction-love.reaction-btn-active {
  background: #ec4899;
  border-color: #ec4899;
}

.reaction-meh.reaction-btn-active {
  background: #64748b;
  border-color: #64748b;
}

@media (max-width: 640px) {
  .reaction-bar {
    margin-top: 0.25rem;
    gap: 0.3rem;
  }

  .reaction-btn {
    padding: 0.24rem 0.48rem;
    font-size: 0.72rem;
    min-height: 28px;
  }
}

.now-playing-banner {
  background: linear-gradient(135deg, rgba(224, 122, 95, 0.12), rgba(129, 178, 154, 0.12));
  border: 1px solid rgba(224, 122, 95, 0.2);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.now-playing-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--terracotta-dark);
  margin-bottom: 0.25rem;
}

.now-playing-track {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.now-playing-track strong {
  font-size: 1rem;
  color: var(--charcoal-dark);
}

.now-playing-track span {
  font-size: 0.85rem;
  color: var(--charcoal-light);
}

.playlist-share {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.share-playlist-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--cream-dark);
  background: var(--white);
  color: var(--charcoal);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 34px;
}

.share-playlist-btn:hover {
  background: var(--cream);
  border-color: var(--sand);
  transform: translateY(-1px);
}

.share-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.share-status {
  font-size: 0.78rem;
  color: var(--sage-dark);
  font-weight: 600;
}

@media (max-width: 640px) {
  .playlist-header {
    align-items: flex-start;
    gap: 0.5rem;
    flex-direction: column;
  }

  .playlist-share {
    width: 100%;
    justify-content: space-between;
  }

  .share-playlist-btn {
    width: 100%;
    justify-content: center;
  }

  .share-status {
    width: 100%;
    text-align: left;
  }
}

.archive-export-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.25rem;
}

@media (max-width: 640px) {
  .archive-export-area {
    width: 100%;
    justify-content: center;
  }
}
