/* ==========================================================================
   Design Tokens
   ========================================================================== */

:root {
  /* Palette */
  --bg: #e6d8c9;
  --bg-warm: #d6c6b4;
  --bg-gradient: linear-gradient(165deg, #efe3d6 0%, #e6d8c9 35%, #dccbb8 100%);
  --ink: #2b2b2b;
  --muted: #6f6a63;
  --accent: #8b7355;

  /* Typography */
  --font: 'Jost', sans-serif;
  --weight-light: 300;
  --weight-regular: 400;
  --weight-medium: 500;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;

  /* Sizing */
  --cover-size: 140px;
  --cover-size-min: 100px;
  --cover-size-lg: 220px;
  --now-playing-height: 80px;
  --header-height: 56px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* Dark mode palette */
[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-warm: #252525;
  --bg-gradient: linear-gradient(165deg, #222222 0%, #1a1a1a 35%, #141414 100%);
  --ink: #e8e4e0;
  --muted: #9a958e;
  --accent: #c4a882;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

body {
  margin: 0;
  font-family: var(--font);
  font-weight: var(--weight-regular);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-fast), color var(--transition-fast);
}

/* Grain overlay - SVG noise filter (no tiling) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: transparent;
  filter: url(#grain);
  opacity: 0.3;
  pointer-events: none;
  z-index: 1000;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   Header
   ========================================================================== */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-md);
  background: var(--bg);
}

.logo {
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.logo-name {
  font-weight: var(--weight-semibold);
  /* color: var(--accent); */
}

.logo-suffix {
  font-weight: var(--weight-light);
  color: var(--accent);
}

.nav {
  display: flex;
  gap: var(--space-sm);
}

.btn-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-sm);
  font-size: 1.25rem;
  color: var(--muted);
  transition: color var(--transition-fast);
}

.btn-nav:hover {
  color: var(--ink);
}

/* ==========================================================================
   Main App Container
   ========================================================================== */

/* ==========================================================================
   Filters
   ========================================================================== */

.filters {
  display: flex;
  gap: 6px;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.filter-btn {
  padding: var(--space-xs) 12px;
  font-size: 0.8125rem;
  font-weight: var(--weight-medium);
  color: var(--muted);
  border-radius: 20px;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  color: var(--ink);
}

.filter-btn.is-active {
  background: var(--ink);
  color: var(--bg);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin-left: 6px;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  font-weight: var(--weight-medium);
  color: var(--ink);
  background: var(--bg-warm);
  border-radius: 20px;
}

.filter-chip.is-hidden {
  display: none;
}

.filter-chip-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 0.875rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.filter-chip-dismiss:hover {
  color: var(--ink);
}

/* ==========================================================================
   Main App Container
   ========================================================================== */

#app {
  padding-bottom: calc(var(--now-playing-height) + var(--space-lg));
}

/* ==========================================================================
   Shelves (Home View)
   ========================================================================== */

.shelves {
  padding: var(--space-md) 0;
}

.no-results {
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  color: var(--muted);
}

.shelf {
  margin-bottom: var(--space-xl);
}

.shelf-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  padding: 0 var(--space-md);
  margin: 0 0 var(--space-md) 0;
}

.shelf-title {
  font-size: 0.75rem;
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.shelf-title:hover {
  color: var(--ink);
}

.shelf-title.is-active {
  color: var(--ink);
}

.shelf-count {
  font-size: 0.6875rem;
  color: var(--muted);
  opacity: 0.7;
}

.shelf-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--cover-size-min), 1fr));
  gap: var(--space-md);
  padding: 0 var(--space-md);
}

/* Album Card */
.album-card {
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.album-card:hover {
  transform: translateY(-4px);
}

.album-card-cover {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
  filter: contrast(0.95) brightness(1.02) saturate(0.85) sepia(0.05);
}

.album-card[data-type="archive"] .album-card-cover {
  object-fit: unset;
}

/* Archive.org-style gradient overlays */
.album-card[data-type="archive"] {
  position: relative;
}

.album-card[data-type="archive"]::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 2px;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.6;
}

.album-card.archive-grad-0::after { background: linear-gradient(135deg, #ff0066 0%, #ff6699 100%); }
.album-card.archive-grad-1::after { background: linear-gradient(135deg, #00cccc 0%, #66ffff 100%); }
.album-card.archive-grad-2::after { background: linear-gradient(135deg, #ff6600 0%, #ffaa66 100%); }
.album-card.archive-grad-3::after { background: linear-gradient(135deg, #9933ff 0%, #cc99ff 100%); }
.album-card.archive-grad-4::after { background: linear-gradient(135deg, #0066ff 0%, #66aaff 100%); }

.album-card-title {
  margin-top: var(--space-sm);
  font-size: 0.8125rem;
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.album-card-artist {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* "More..." tile */
.album-card-more {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.album-card-more-inner {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-warm);
  border: 2px dashed var(--muted);
  border-radius: 2px;
  color: var(--muted);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.album-card-more:hover .album-card-more-inner {
  border-color: var(--ink);
  color: var(--ink);
}

.album-card-more-count {
  font-size: 1.5rem;
  font-weight: var(--weight-medium);
}

.album-card-more-label {
  font-size: 0.8125rem;
}

/* ==========================================================================
   Album Detail View
   ========================================================================== */

.album-view {
  padding: var(--space-md);
  max-width: 800px;
  margin: 0 auto;
}

.album-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: var(--space-lg);
  transition: color var(--transition-fast);
}

.album-back:hover {
  color: var(--ink);
}

.album-header {
  display: grid;
  grid-template-columns: var(--cover-size-lg) 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.album-cover {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
  filter: contrast(0.95) brightness(1.02) saturate(0.85) sepia(0.05);
}

.album-view[data-type="archive"] .album-cover {
  object-fit: unset;
}

/* Archive.org-style gradient overlays for album view */
.album-cover-wrap {
  position: relative;
  display: inline-block;
}

/* Constrain archive cover wrap to image dimensions */
.album-view[data-type="archive"] .album-cover-wrap {
  overflow: hidden;
  border-radius: 2px;
}

.album-cover-wrap.archive-grad-0::after,
.album-cover-wrap.archive-grad-1::after,
.album-cover-wrap.archive-grad-2::after,
.album-cover-wrap.archive-grad-3::after,
.album-cover-wrap.archive-grad-4::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.6;
}

.album-cover-wrap.archive-grad-0::after { background: linear-gradient(135deg, #ff0066 0%, #ff6699 100%); }
.album-cover-wrap.archive-grad-1::after { background: linear-gradient(135deg, #00cccc 0%, #66ffff 100%); }
.album-cover-wrap.archive-grad-2::after { background: linear-gradient(135deg, #ff6600 0%, #ffaa66 100%); }
.album-cover-wrap.archive-grad-3::after { background: linear-gradient(135deg, #9933ff 0%, #cc99ff 100%); }
.album-cover-wrap.archive-grad-4::after { background: linear-gradient(135deg, #0066ff 0%, #66aaff 100%); }

.album-meta {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.album-title {
  margin: 0 0 var(--space-xs) 0;
  font-size: 1.5rem;
  font-weight: var(--weight-medium);
}

.album-artist {
  margin: 0 0 var(--space-sm) 0;
  font-size: 1rem;
  color: var(--muted);
}

.album-artist-link {
  display: block;
  margin: 0 0 var(--space-sm) 0;
  font-size: 1rem;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.album-artist-link:hover {
  color: var(--ink);
}

.album-tags {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.album-tag {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.6875rem;
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  background: var(--bg-warm);
  border-radius: 2px;
  color: var(--muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.album-tag:hover {
  background: var(--ink);
  color: var(--bg);
}

.album-year {
  font-size: 0.875rem;
  color: var(--muted);
}

.album-type-badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.6875rem;
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-warm);
  border-radius: 2px;
  color: var(--muted);
}

.album-description {
  margin-top: var(--space-md);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--muted);
  max-width: 45ch;
}

.album-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.btn-play-album {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-weight: var(--weight-medium);
  background: var(--ink);
  color: var(--bg);
  border-radius: 4px;
  transition: opacity var(--transition-fast);
}

.btn-play-album:hover {
  opacity: 0.85;
}

.btn-purchase {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-weight: var(--weight-medium);
  border: 1px solid var(--muted);
  border-radius: 4px;
  color: var(--muted);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.btn-purchase:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* Tracklist */
.tracklist {
  border-top: 1px solid rgba(0,0,0,0.1);
}

.track {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.track:hover {
  background: rgba(0,0,0,0.03);
  margin: 0 calc(-1 * var(--space-md));
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

.track-num {
  width: 24px;
  font-size: 0.875rem;
  color: var(--muted);
  text-align: right;
}

.track-title {
  flex: 1;
  font-size: 0.9375rem;
}

.track-duration {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-right: var(--space-lg);
}

.track.is-playing {
  color: var(--accent);
}

.track.is-playing .track-num {
  color: var(--accent);
}

/* Taper Notes (Archive.org recordings) */
.taper-notes {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(0,0,0,0.1);
}

.taper-notes-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 var(--space-md) 0;
}

.taper-notes-content {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--ink);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  white-space: pre-wrap;
  background: rgba(0,0,0,0.03);
  padding: var(--space-md);
  border-radius: 4px;
  overflow-x: auto;
}

.taper-notes-link {
  display: inline-block;
  margin-top: var(--space-md);
  font-size: 0.875rem;
  color: var(--accent);
  text-decoration: none;
}

.taper-notes-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Now Playing Bar
   ========================================================================== */

.now-playing {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--now-playing-height);
  background: var(--bg-warm);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0,0,0,0.1);
  transform: translateY(100%);
  transition: transform var(--transition-normal), background var(--transition-fast);
}

[data-theme="dark"] .now-playing {
  border-top-color: rgba(255,255,255,0.1);
}

.now-playing.is-visible {
  transform: translateY(0);
}

.now-playing[hidden] {
  display: block !important; /* Override hidden to allow transition */
}

/* Loading state for play button */
.btn-play-album.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.np-inner {
  display: grid;
  grid-template-columns: 60px 1fr auto auto auto;
  gap: var(--space-md);
  align-items: center;
  height: 100%;
  padding: 0 var(--space-md);
}

.np-cover-wrap {
  position: relative;
  width: 60px;
  height: 60px;
  flex-shrink: 0;
}

.np-cover {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 2px;
}

/* Archive waveforms should stretch to fill the square (matching album cover) */
.np-cover-wrap[class*="archive-grad"] .np-cover {
  object-fit: fill;
}

/* Archive.org gradient overlays for now-playing cover */
.np-cover-wrap.archive-grad-0::after,
.np-cover-wrap.archive-grad-1::after,
.np-cover-wrap.archive-grad-2::after,
.np-cover-wrap.archive-grad-3::after,
.np-cover-wrap.archive-grad-4::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.6;
}

.np-cover-wrap.archive-grad-0::after { background: linear-gradient(135deg, #ff0066 0%, #ff6699 100%); }
.np-cover-wrap.archive-grad-1::after { background: linear-gradient(135deg, #00cccc 0%, #66ffff 100%); }
.np-cover-wrap.archive-grad-2::after { background: linear-gradient(135deg, #ff6600 0%, #ffaa66 100%); }
.np-cover-wrap.archive-grad-3::after { background: linear-gradient(135deg, #9933ff 0%, #cc99ff 100%); }
.np-cover-wrap.archive-grad-4::after { background: linear-gradient(135deg, #0066ff 0%, #66aaff 100%); }

.np-info {
  min-width: 0;
}

.np-track {
  font-size: 0.875rem;
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-album {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.np-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--ink);
  transition: opacity var(--transition-fast);
}

.np-btn:hover {
  opacity: 0.7;
}

.np-btn-play {
  width: 44px;
  height: 44px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 50%;
}

.np-btn-play:hover {
  opacity: 0.85;
}

.np-btn-play .is-hidden {
  display: none;
}

.np-btn-play .icon-loading {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Play Mode Indicator
   ========================================================================== */

.np-mode {
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  padding: 2px;
}

.np-mode-btn {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  font-weight: var(--weight-medium);
  color: var(--muted);
  border-radius: 3px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.np-mode-btn:hover {
  color: var(--ink);
}

.np-mode-btn.is-active {
  background: var(--ink);
  color: var(--bg);
}

.np-mode-btn.is-pending {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.np-mode-btn.is-hidden {
  display: none;
}

.np-progress {
  display: none;
  flex-direction: column;
  gap: 2px;
  width: 200px;
}

.np-seek {
  width: 100%;
  height: 4px;
  appearance: none;
  background: rgba(0,0,0,0.15);
  border-radius: 2px;
  cursor: pointer;
}

.np-seek::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--ink);
  border-radius: 50%;
}

.np-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--muted);
}

/* Idle state */
.np-idle {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0 var(--space-md);
}

.np-idle.is-hidden,
.np-inner.is-hidden {
  display: none !important;
}

.btn-random-song {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9375rem;
  font-weight: var(--weight-medium);
  border-radius: 100px;
  transition: opacity var(--transition-fast);
}

.btn-random-song:hover {
  opacity: 0.85;
}

.btn-random-song svg {
  opacity: 0.8;
}

.btn-resume-queue {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: transparent;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: var(--weight-medium);
  border: 1px solid var(--ink);
  border-radius: 100px;
  margin-left: var(--space-md);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-resume-queue:hover {
  background: var(--ink);
  color: var(--bg);
}

.btn-resume-queue.is-hidden {
  display: none;
}

.btn-resume-queue svg {
  opacity: 0.8;
}


/* ==========================================================================
   Drawer
   ========================================================================== */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.drawer-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100%;
  background: var(--bg);
  z-index: 301;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.drawer-tabs {
  display: flex;
  gap: var(--space-sm);
}

.drawer-tab {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.875rem;
  font-weight: var(--weight-medium);
  color: var(--muted);
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.drawer-tab:hover {
  color: var(--ink);
}

.drawer-tab.is-active {
  background: var(--ink);
  color: var(--bg);
}

.drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  transition: color var(--transition-fast);
}

.drawer-close:hover {
  color: var(--ink);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
}

.drawer-panel {
  display: none;
  padding: var(--space-md);
}

.drawer-panel.is-active {
  display: block;
}

.drawer-empty {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--muted);
}

.drawer-empty p {
  margin: 0;
}

.drawer-empty-hint {
  font-size: 0.8125rem;
  margin-top: var(--space-sm) !important;
  opacity: 0.7;
}

.drawer-empty.is-hidden {
  display: none;
}

.drawer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: 4px;
  transition: background var(--transition-fast);
}

.drawer-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.drawer-item--clickable {
  cursor: pointer;
}

.drawer-item-thumb {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 2px;
  overflow: hidden;
}

.drawer-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Archive waveforms should stretch to fill the square (matching album cover) */
.drawer-item-thumb[class*="archive-grad"] img {
  object-fit: fill;
}

/* Archive gradient overlays for drawer thumbnails */
.drawer-item-thumb.archive-grad-0::after,
.drawer-item-thumb.archive-grad-1::after,
.drawer-item-thumb.archive-grad-2::after,
.drawer-item-thumb.archive-grad-3::after,
.drawer-item-thumb.archive-grad-4::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.6;
}

.drawer-item-thumb.archive-grad-0::after { background: linear-gradient(135deg, #ff0066 0%, #ff6699 100%); }
.drawer-item-thumb.archive-grad-1::after { background: linear-gradient(135deg, #00cccc 0%, #66ffff 100%); }
.drawer-item-thumb.archive-grad-2::after { background: linear-gradient(135deg, #ff6600 0%, #ffaa66 100%); }
.drawer-item-thumb.archive-grad-3::after { background: linear-gradient(135deg, #9933ff 0%, #cc99ff 100%); }
.drawer-item-thumb.archive-grad-4::after { background: linear-gradient(135deg, #0066ff 0%, #66aaff 100%); }

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

.drawer-item-title {
  font-size: 0.875rem;
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-item-album {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-item-time {
  font-size: 0.6875rem;
  color: var(--muted);
  opacity: 0.7;
}

.drawer-item-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--muted);
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.drawer-item:hover .drawer-item-remove {
  opacity: 1;
}

.drawer-item-remove:hover {
  color: var(--ink);
}

.drawer-footer {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.drawer-action {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8125rem;
  font-weight: var(--weight-medium);
  color: var(--muted);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.drawer-action:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.drawer-action-danger:hover {
  color: #c53030;
  border-color: #c53030;
}

.drawer-action.is-hidden {
  display: none;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal-overlay.is-hidden {
  display: none;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: var(--weight-medium);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--ink);
}

.modal-body {
  padding: var(--space-md);
}

.modal-hint {
  margin: 0 0 var(--space-md) 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.modal-textarea {
  width: 100%;
  height: 200px;
  padding: var(--space-md);
  font-family: inherit;
  font-size: 0.875rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  background: var(--bg-warm);
  resize: vertical;
}

.modal-textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.modal-result {
  margin-top: var(--space-md);
  padding: var(--space-md);
  font-size: 0.8125rem;
  background: var(--bg-warm);
  border-radius: 4px;
}

.modal-result.is-hidden {
  display: none;
}

.modal-result-success {
  color: #2f855a;
}

.modal-result-warning {
  color: #b7791f;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-btn {
  padding: var(--space-sm) var(--space-lg);
  font-size: 0.875rem;
  font-weight: var(--weight-medium);
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.modal-btn-secondary {
  color: var(--muted);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.modal-btn-secondary:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.modal-btn-primary {
  background: var(--ink);
  color: var(--bg);
}

.modal-btn-primary:hover {
  opacity: 0.85;
}

/* ==========================================================================
   Track Add to Queue Button
   ========================================================================== */

.track {
  position: relative;
}

.track-add-queue {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--muted);
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.track:hover .track-add-queue {
  opacity: 1;
}

.track-add-queue:hover {
  color: var(--accent);
}

/* ==========================================================================
   Add to Playlist Popover
   ========================================================================== */

.add-popover {
  position: fixed;
  z-index: 350;
  background: var(--bg);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  padding: var(--space-xs);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.add-popover.is-hidden {
  display: none;
}

.add-popover-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-weight: var(--weight-medium);
  color: var(--ink);
  border-radius: 4px;
  white-space: nowrap;
  transition: background var(--transition-fast);
}

.add-popover-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.add-popover-btn svg {
  color: var(--muted);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (min-width: 640px) {
  :root {
    --cover-size-min: 130px;
  }
}

@media (min-width: 768px) {
  :root {
    --cover-size-min: 150px;
    --cover-size-lg: 280px;
  }

  .album-header {
    gap: var(--space-xl);
  }

  .album-title {
    font-size: 2rem;
  }

  .np-progress {
    display: flex;
  }
}

@media (max-width: 767px) {
  :root {
    --now-playing-height: auto;
  }

  #app {
    padding-bottom: 140px; /* Fixed padding for mobile player */
  }

  .now-playing {
    height: auto;
  }

  .album-header {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .album-cover-wrap {
    max-width: var(--cover-size-lg);
    margin: 0 auto;
  }

  .album-cover {
    max-width: var(--cover-size-lg);
    margin: 0 auto;
  }

  .album-tags {
    justify-content: center;
  }

  .album-description {
    max-width: none;
  }

  .album-actions {
    justify-content: center;
  }

  .np-inner {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    grid-template-rows: auto auto auto;
    gap: var(--space-sm) var(--space-md);
    padding: var(--space-sm) var(--space-md) calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
    height: auto;
  }

  .np-cover-wrap {
    width: 44px;
    height: 44px;
    grid-row: 1;
  }

  .np-cover {
    width: 44px;
    height: 44px;
  }

  .np-info {
    grid-row: 1;
  }

  .np-mode {
    grid-row: 1;
    padding: 1px;
    gap: 1px;
  }

  .np-mode-btn {
    padding: 3px 6px;
    font-size: 0.6875rem;
  }

  .np-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
    gap: var(--space-md);
  }

  .np-progress {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
  }

  .np-time {
    display: none;
  }

  .np-idle {
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-md) calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  }

  .btn-resume-queue {
    margin-left: 0;
  }

  .drawer {
    width: 100%;
    border-radius: 0;
  }
}

/* ==========================================================================
   Info Modal / FAQ
   ========================================================================== */

.modal-info {
  max-width: 480px;
}

.modal-body-scroll {
  max-height: 60vh;
  overflow-y: auto;
}

.faq {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.faq-item {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: var(--space-sm);
}

.faq-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-question {
  font-weight: 500;
  cursor: pointer;
  padding: var(--space-xs) 0;
  list-style: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::before {
  content: '+';
  display: inline-block;
  width: 1.25em;
  font-weight: 400;
  color: var(--muted);
}

details[open] .faq-question::before {
  content: '−';
}

.faq-answer {
  margin: var(--space-xs) 0 0 1.25em;
  font-size: 0.9375rem;
  color: var(--muted);
  line-height: 1.5;
}

.faq-answer a {
  color: var(--ink);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast {
  position: fixed;
  bottom: calc(var(--now-playing-height) + var(--space-md));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  padding: var(--space-sm) var(--space-md);
  border-radius: 6px;
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1100;
  max-width: calc(100% - var(--space-lg) * 2);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.is-hidden {
  display: none;
}

/* ==========================================================================
   Theme Toggle
   ========================================================================== */

.btn-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-sm);
  color: var(--muted);
  transition: color var(--transition-fast);
}

.btn-theme:hover {
  color: var(--ink);
}

.btn-theme .icon-sun,
.btn-theme .icon-moon {
  display: none;
}

.btn-theme .icon-moon {
  display: block;
}

[data-theme="dark"] .btn-theme .icon-moon {
  display: none;
}

[data-theme="dark"] .btn-theme .icon-sun {
  display: block;
}

/* ==========================================================================
   Drawer Info Link
   ========================================================================== */

.drawer-info-link {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-left: auto;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8125rem;
  color: var(--muted);
  transition: color var(--transition-fast);
}

.drawer-info-link:hover {
  color: var(--ink);
}

/* ==========================================================================
   Dark Mode Adjustments
   ========================================================================== */

[data-theme="dark"] .filters {
  border-bottom-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .tracklist {
  border-top-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .track {
  border-bottom-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .track:hover {
  background: rgba(255,255,255,0.03);
}

[data-theme="dark"] .drawer-header,
[data-theme="dark"] .drawer-footer,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .drawer-item:hover {
  background: rgba(255,255,255,0.05);
}

[data-theme="dark"] .drawer-action {
  border-color: rgba(255,255,255,0.15);
}

[data-theme="dark"] .modal-textarea {
  border-color: rgba(255,255,255,0.15);
}

[data-theme="dark"] .add-popover {
  border-color: rgba(255,255,255,0.15);
}

[data-theme="dark"] .add-popover-btn:hover {
  background: rgba(255,255,255,0.05);
}

[data-theme="dark"] .taper-notes {
  border-top-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .taper-notes-content {
  background: rgba(255,255,255,0.03);
}

[data-theme="dark"] .faq-item {
  border-bottom-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .np-mode {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .np-seek {
  background: rgba(255,255,255,0.15);
}
