/* ── Color tokens ── */
:root {
  --color-bg:               #1a1a1a;
  --color-surface:          #2a2a2a;
  --color-surface-raised:   #333333;
  --color-surface-selected: #3d2d6b;
  --color-text:             #e2e8f0;
  --color-text-muted:       #94a3b8;
  --color-text-dim:         #64748b;
  --color-accent:           #7c3aed;
  --color-accent-bright:    #a78bfa;
  --color-border:           #3a3a3a;
  --color-player-bg:        #222222;
  --color-scrubber-track:   #4a4a4a;
  --color-scrubber-fill:    #7c3aed;

  /* scrubber progress fill, driven by JS */
  --scrubber-progress: 0%;
  --volume-level: 100%;
}

/* ── Paused notice ── */
.cmus-paused-banner {
  grid-column: 1 / -1;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  padding: 12px 20px;
  font-size: 14px;
  text-align: center;
}
.cmus-paused-banner strong { color: var(--color-text); }
.cmus-paused-banner a { color: var(--color-accent-bright); text-decoration: none; margin-left: 8px; }
.cmus-paused-banner a:hover { text-decoration: underline; }

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

/* ── Base ── */
html, body {
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ── Layout grid ── */
.library-layout {
  display: grid;
  grid-template-rows: 48px 1fr 72px;
  grid-template-columns: 220px 260px 1fr;
  height: 100vh;
  overflow: hidden;
}

.library-header { grid-column: 1 / -1; }
.library-player { grid-column: 1 / -1; }

/* ── Header ── */
.library-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  flex-shrink: 0;
}
.logo span { color: var(--color-accent); }

/* ── Nav ── */
.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 4px 8px;
  border-bottom: 2px solid transparent;
  transition: color 150ms ease, border-color 150ms ease;
  line-height: 1;
  /* align border-bottom with header bottom edge */
  margin-bottom: -1px;
}
.nav-link:hover { color: var(--color-text); }
.nav-link--active {
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
}
.nav-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── Library columns ── */
.library-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  overflow: hidden;
  background: var(--color-bg);
}
.library-col:last-of-type {
  border-right: none;
}

/* ── Column header ── */
.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.col-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-dim);
}

.col-count {
  font-size: 11px;
  color: var(--color-text-dim);
  font-variant-numeric: tabular-nums;
}

/* ── Scrollable column body ── */
.col-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  outline: none;
}
.col-scroll:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* ── Empty state ── */
.col-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 120px;
  font-size: 13px;
  color: var(--color-text-dim);
  padding: 24px;
  text-align: center;
}

.col-empty-state a {
  color: var(--color-accent);
  text-decoration: none;
}
.col-empty-state a:hover { text-decoration: underline; }

/* ── Fade-in on content load ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.list-fade-in {
  animation: fadeIn 150ms ease-out forwards;
}

/* ── Skeleton loading ── */
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
.skeleton-row {
  background: linear-gradient(
    90deg,
    var(--color-surface-raised) 25%,
    #3a3a3a 50%,
    var(--color-surface-raised) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 4px;
  margin: 4px 12px;
}
.skeleton-row--artist { height: 48px; }
.skeleton-row--album  { height: 56px; }
.skeleton-row--track  { height: 40px; }

/* ── Artist list item ── */
.artist-item {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 16px;
  cursor: pointer;
  position: relative;
  transition: background 150ms ease;
  border-left: 3px solid transparent;
  user-select: none;
}
.artist-item:hover {
  background: var(--color-surface-raised);
}
.artist-item[aria-selected="true"] {
  background: var(--color-surface-selected);
  border-left-color: var(--color-accent);
  padding-left: 13px;
}
.artist-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.artist-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}
.artist-item[aria-selected="true"] .artist-name {
  color: var(--color-text);
}

/* Playing indicator: 6px filled circle after name */
.artist-item.has-playing .artist-name::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
  margin-left: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}

.artist-chevron {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--color-text-dim);
  margin-left: 4px;
}

/* ── Art placeholder (shared by artists and albums) ── */
.art-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: var(--color-surface-raised);
  color: var(--color-text-dim);
  flex-shrink: 0;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.art-placeholder img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.art-placeholder:hover::after {
  content: "＋";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  font-size: 18px;
  color: #fff;
  border-radius: 4px;
}

/* ── Album card ── */
.album-item {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 16px;
  gap: 10px;
  cursor: pointer;
  position: relative;
  transition: background 150ms ease;
  border-left: 3px solid transparent;
  user-select: none;
}
.album-item:hover {
  background: var(--color-surface-raised);
}
.album-item[aria-selected="true"] {
  background: var(--color-surface-selected);
  border-left-color: var(--color-accent);
  padding-left: 13px;
}
.album-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.album-art {
  width: 40px;
  height: 40px;
}

.album-text {
  flex: 1;
  min-width: 0;
}

.album-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}

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

.album-chevron {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--color-text-dim);
  margin-left: 4px;
}

/* ── Tracks column header row ── */
.tracks-header-row {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 8px 0 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}
.tracks-header-num {
  width: 28px;
  text-align: right;
  font-size: 11px;
  color: var(--color-text-dim);
  padding-right: 8px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tracks-header-title {
  flex: 1;
  font-size: 11px;
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tracks-header-dur {
  width: 64px;
  text-align: right;
  font-size: 11px;
  color: var(--color-text-dim);
  padding-right: 8px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Track row ── */
.track-item {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 8px 0 0;
  cursor: pointer;
  transition: background 150ms ease;
  user-select: none;
}
.track-item:hover {
  background: var(--color-surface-raised);
}
.track-item[aria-selected="true"] {
  background: var(--color-surface-selected);
}
.track-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.track-num {
  width: 28px;
  text-align: right;
  padding-right: 8px;
  font-size: 12px;
  font-family: "SF Mono", "Consolas", "Liberation Mono", monospace;
  color: var(--color-text-dim);
  flex-shrink: 0;
}

/* EQ bars replace the track number when playing */
.eq-bars {
  display: none;
  width: 28px;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 100%;
  padding-right: 6px;
  flex-shrink: 0;
}
.track-item.is-playing .track-num  { display: none; }
.track-item.is-playing .eq-bars    { display: flex; }
.track-item.unavailable { opacity: 0.4; }
.track-item.unavailable .track-title { color: var(--color-text-dim); }

@keyframes eq-bounce {
  from { height: 3px; }
  to   { height: 12px; }
}
.eq-bar {
  width: 3px;
  background: var(--color-accent);
  border-radius: 1px;
  animation: eq-bounce 0.8s ease-in-out infinite alternate;
  height: 3px;
}
.eq-bar:nth-child(2) { animation-delay: 0.15s; }
.eq-bar:nth-child(3) { animation-delay: 0.3s; }

/* Paused: freeze animation */
.track-item.is-paused .eq-bar { animation-play-state: paused; }

.track-title {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text);
}
.track-item.is-playing .track-title { color: var(--color-accent-bright); }

.track-dur {
  width: 64px;
  text-align: right;
  padding-right: 8px;
  font-size: 12px;
  font-family: "SF Mono", "Consolas", "Liberation Mono", monospace;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ── Player bar ── */
.library-player {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  background: var(--color-player-bg);
  border-top: 1px solid var(--color-border);
  height: 72px;
  z-index: 10;
}

.player-art {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: var(--color-surface-raised);
  color: var(--color-text-dim);
  overflow: hidden;
  margin-right: 10px;
  position: relative;
}
.player-art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-info {
  width: 200px;
  flex-shrink: 0;
  min-width: 0;
  margin-right: 16px;
}

.player-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  color: var(--color-text-dim);
}
/* Override dim when something is loaded */
.player-title.has-track { color: var(--color-text); }

.player-artist {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  margin-top: 1px;
}

/* Center spacer */
.player-spacer { flex: 1; }

/* Controls */
.player-controls-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.player-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 150ms ease, background 150ms ease;
  padding: 0;
  flex-shrink: 0;
}
.player-btn:hover  { color: var(--color-text); }
.player-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.player-btn--primary {
  background: var(--color-accent);
  color: #fff;
  width: 40px;
  height: 40px;
}
.player-btn--primary:hover {
  background: #6d28d9;
  color: #fff;
}

/* Disabled state for controls and scrubbers */
.player-controls-wrap[aria-disabled="true"],
#player-scrubber-wrap[aria-disabled="true"],
#player-volume-wrap[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

/* Scrubber section */
.player-scrubber-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 16px;
}

.player-time {
  font-size: 12px;
  font-family: "SF Mono", "Consolas", "Liberation Mono", monospace;
  color: var(--color-text-muted);
  white-space: nowrap;
  width: 80px;
  text-align: right;
}

/* Volume section */
.player-volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.player-vol-icon {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 150ms ease;
}
.player-vol-icon:hover { color: var(--color-text); }
.player-vol-icon:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 3px; }

/* ── Range inputs ── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  cursor: pointer;
  outline: none;
  /* filled portion via gradient; --scrubber-progress / --volume-level driven by JS */
}
input[type="range"]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
}

.player-scrubber {
  width: 200px;
  background: linear-gradient(
    to right,
    var(--color-scrubber-fill) var(--scrubber-progress),
    var(--color-scrubber-track) var(--scrubber-progress)
  );
}

.player-volume {
  width: 80px;
  background: linear-gradient(
    to right,
    var(--color-scrubber-fill) var(--volume-level),
    var(--color-scrubber-track) var(--volume-level)
  );
}

.track-item.unavailable .track-title::after {
  content: ' — not found';
  font-style: italic;
  font-weight: 400;
}
