:root {
  --bg: #12100e;
  --bg-elevated: #1a1714;
  --bg-card: #1f1b17;
  --border: rgba(255, 236, 210, 0.08);
  --text: #f5efe6;
  --text-muted: rgba(245, 239, 230, 0.55);
  --accent: #e8a54b;
  --accent-dim: rgba(232, 165, 75, 0.15);
  --accent-glow: rgba(232, 165, 75, 0.35);
  --radius: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 1.25rem 1.5rem 2.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.brand-mark {
  font-size: 1.5rem;
  color: var(--accent);
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.brand-sub {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.controls {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.field input {
  width: 11rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.queue-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  cursor: default;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.queue-badge.pulse {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.queue-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

#queueCount {
  font-weight: 600;
  color: var(--accent);
  min-width: 1.25rem;
  text-align: center;
}

.agent-banner {
  margin: 0 0 1rem;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.agent-banner.warn {
  border-color: rgba(232, 120, 75, 0.45);
  background: rgba(232, 120, 75, 0.1);
  color: #f0c9a8;
}

.agent-banner.ok {
  border-color: rgba(120, 200, 140, 0.35);
  color: #b8e0c4;
}

.search-row {
  margin-bottom: 1rem;
}

#search {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}

#search:focus {
  outline: none;
  border-color: rgba(232, 165, 75, 0.45);
}

.genre-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.genre-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem 0.35rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.genre-btn img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
}

.genre-btn.active,
.genre-btn:hover {
  color: var(--text);
  border-color: rgba(232, 165, 75, 0.5);
  background: var(--accent-dim);
}

.genre-btn.active {
  color: var(--accent);
}

.main {
  min-height: 200px;
}

.loading,
.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 3rem 1rem;
}

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

.album-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.album-card:hover {
  border-color: rgba(232, 165, 75, 0.25);
}

.album-head {
  display: flex;
  gap: 0.85rem;
  padding: 0.85rem;
  align-items: center;
}

.cover-wrap {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(145deg, #2a2420, #151210);
  border: 1px solid var(--border);
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-muted);
}

.album-meta h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.2;
}

.album-meta p {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.track-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}

.track-item:last-child {
  border-bottom: none;
}

.track-item:hover {
  background: var(--accent-dim);
}

.track-item:active {
  background: rgba(232, 165, 75, 0.22);
}

.track-item.queued {
  background: rgba(232, 165, 75, 0.12);
}

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

.track-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.track-action {
  flex-shrink: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.12s;
}

.track-item:hover .track-action {
  opacity: 1;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.85rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  z-index: 100;
  animation: toast-in 0.25s ease;
}

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

@media (max-width: 600px) {
  body {
    padding: 1rem;
  }

  .top {
    flex-direction: column;
    align-items: stretch;
  }

  .controls {
    flex-wrap: wrap;
  }

  .field input {
    width: 100%;
  }
}
