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

:root {
  --bg: #0c0c0e;
  --surface: #161618;
  --border: rgba(255,255,255,0.07);
  --text: #ececec;
  --muted: #6e6e78;
  --gap: 3px;
  --radius: 4px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ===== LANDING ===== */
.view-landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.landing-inner {
  text-align: center;
  max-width: 460px;
  width: 100%;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}

.tagline {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.6rem;
}

.sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.search-row {
  display: flex;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}

.search-row select {
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.search-row select:focus { border-color: rgba(255,255,255,0.18); }

.search-row input {
  flex: 1;
  height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.search-row input::placeholder { color: #444; }
.search-row input:focus { border-color: rgba(255,255,255,0.18); }

.search-row button {
  height: 44px;
  padding: 0 20px;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.search-row button:hover { opacity: 0.88; }

.error {
  color: #e55;
  font-size: 0.82rem;
  margin-top: 0.8rem;
  min-height: 1.2em;
}

/* ===== BAR (header) ===== */
.bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(12,12,14,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.bar-left {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.bar-brand {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.bar-sep {
  color: var(--muted);
  font-size: 0.82rem;
  flex-shrink: 0;
}

.bar-user {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-right {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.35; pointer-events: none; }

.btn-download {
  background: #fff;
  color: #000;
}

.btn-new {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-new:hover { color: var(--text); border-color: rgba(255,255,255,0.14); }

/* ===== LOADING ===== */
.loading {
  display: flex;
  justify-content: center;
  padding: 6rem 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(255,255,255,0.08);
  border-top-color: rgba(255,255,255,0.5);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

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

/* ===== GRID ===== */
.grid-wrap {
  padding: var(--gap);
  max-width: 1400px;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
}

/* #1 spans 2 cols */
.grid .cell:first-child {
  grid-column: span 2;
  grid-row: span 1;
}

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(5, 1fr); }
  .grid .cell:first-child { grid-column: span 2; }
}

@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(6, 1fr); }
  .grid .cell:first-child { grid-column: span 2; }
}

@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(7, 1fr); }
  .grid .cell:first-child { grid-column: span 2; }
}

/* ===== CELL ===== */
.cell {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cell:hover img {
  transform: scale(1.04);
}

.cell-info {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.15) 50%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px 12px;
  opacity: 0;
  transition: opacity 0.25s;
}

.cell:hover .cell-info { opacity: 1; }

.cell-rank {
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
}

.cell-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-plays {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
}

.cell-artist {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fallback gradient when no image */
.cell.nofill {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
}

.cell.nofill .cell-info {
  opacity: 1;
  background: linear-gradient(135deg, rgba(26,26,46,0.9), rgba(22,33,62,0.9));
}
