:root {
  --bg: #0e1116;
  --panel: #171b24;
  --panel-2: #1d2230;
  --border: #262c3a;
  --text: #e9edf6;
  --muted: #8b94a8;
  --accent: #60a5fa;
  --c-s: #ff5d5d;
  --c-a: #ff9b3d;
  --c-b: #ffd43d;
  --c-c: #7fd057;
  --c-d: #4fa3ff;
  --c-f: #7d869b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 500px at 70% -10%, #1a2233 0%, transparent 60%), var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(14, 17, 22, .82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 8px;
}

.list-name {
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  border-bottom: 1px dashed transparent;
  padding: 4px 6px;
  border-radius: 6px;
  max-width: 340px;
  width: 100%;
}
.list-name:hover { border-bottom-color: var(--border); }
.list-name:focus { border-bottom-color: var(--accent); background: var(--panel-2); }

.actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #252c3d; border-color: #343c50; }
.btn:active { transform: translateY(1px); }
.btn-danger { color: #ffb4ae; }
.btn-danger:hover { background: #3a2328; border-color: #5b3038; }

.search-wrap {
  padding: 22px 24px 0;
  max-width: 1300px;
  margin: 0 auto;
}

.type-select {
  display: inline-flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin: 0 0 12px;
}

.type-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.type-btn:hover { color: var(--text); }
.type-btn.active { background: var(--panel-2); color: var(--text); }

.song-context {
  max-width: 1300px;
  margin: 18px auto 0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.song-context-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(96, 165, 250, .1);
  border: 1px solid rgba(96, 165, 250, .35);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
}

.song-context-info img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #0a0c10;
}

.song-context-info .song-artist { color: var(--muted); font-size: 12px; margin-top: 1px; }

.search-box { position: relative; max-width: 560px; }

#search-input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(96, 165, 250, .15); }
#search-input::placeholder { color: var(--muted); }

.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  max-height: 420px;
  overflow: auto;
  z-index: 30;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  padding: 10px;
}

.result-card {
  display: flex;
  gap: 10px;
  align-items: center;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: background .12s, border-color .12s;
}
.result-card:hover { background: #252c3d; border-color: var(--accent); }

.result-card img,
.result-fallback {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #000;
}

.result-fallback {
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  background: linear-gradient(135deg, #1a2030, #0c0e15);
  border: 1px solid var(--border);
}

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

.result-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-artist {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.results-status { padding: 24px 16px; color: var(--muted); text-align: center; font-size: 14px; }
.hidden { display: none !important; }

main {
  max-width: 1300px;
  margin: 26px auto 48px;
  padding: 0 24px;
  display: grid;
  gap: 18px;
}

.board { display: grid; gap: 10px; }

.tier {
  display: grid;
  grid-template-columns: 64px 1fr;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tier .badge {
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
  color: #0e1116;
}
.tier[data-tier="S"] .badge { background: var(--c-s); }
.tier[data-tier="A"] .badge { background: var(--c-a); }
.tier[data-tier="B"] .badge { background: var(--c-b); }
.tier[data-tier="C"] .badge { background: var(--c-c); }
.tier[data-tier="D"] .badge { background: var(--c-d); }
.tier[data-tier="F"] .badge { background: var(--c-f); }

.slot {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  padding: 12px;
  min-height: 118px;
  align-content: start;
  transition: background .12s;
}
.slot.over { background: rgba(96, 165, 250, .12); }

.slot-pool { min-height: 96px; outline: 1px dashed transparent; }
.slot-pool.empty { outline-color: var(--border); }
.slot-pool.empty::before {
  content: "Search above to add albums";
  color: var(--muted);
  font-size: 13px;
  display: grid;
  place-items: center;
  grid-column: 1 / -1;
  min-height: 72px;
}
.slot-pool.over { outline-color: var(--accent); background: rgba(96, 165, 250, .08); }

.tile {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .1s, box-shadow .1s, opacity .1s, border-color .1s;
  animation: pop .18s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, .4); border-color: #343c50; }
.tile:active { cursor: grabbing; }
.tile.dragging { opacity: .35; }

.tile .art {
  aspect-ratio: 1;
  background: #0a0c10;
  font-size: 22px;
  font-weight: 700;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.tile .art img { width: 100%; height: 100%; object-fit: cover; display: block; }

.tile .tile-meta { padding: 7px 9px 9px; }

.tile-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-artist {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

@keyframes pop {
  from { transform: scale(.92); opacity: .4; }
  to { transform: scale(1); opacity: 1; }
}

.pool {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pool-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 16px 0;
}

.pool-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.count { font-size: 12px; color: var(--muted); }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1f2636;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.tab {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--text); }

.community {
  max-width: 1300px;
  margin: 26px auto 48px;
  padding: 0 24px;
}

.community-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.community-head h2 { margin: 0; font-size: 20px; }

.community-sorts { display: flex; gap: 6px; }

.btn.accent {
  background: rgba(96, 165, 250, .16);
  border-color: #3b82f6;
  color: #bbd6ff;
}
.btn.accent:hover { background: rgba(96, 165, 250, .26); }

.btn.chip { padding: 7px 12px; }
.btn.chip.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }

.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.community-card {
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: border-color .12s, transform .12s;
}
.community-card:hover { border-color: #3b82f6; transform: translateY(-2px); }

.card-art {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 20px;
}
.card-art img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-body { min-width: 0; }
.card-title {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.overlay-scrim { position: absolute; inset: 0; background: rgba(5, 7, 10, .7); }

.overlay-panel {
  position: relative;
  width: min(900px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  padding: 20px;
}

.overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.overlay-head h3 { margin: 0 0 4px; font-size: 20px; }
.overlay-sub { font-size: 13px; color: var(--muted); }

.detail-votes { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

.vote {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  gap: 6px;
  align-items: center;
}
.vote:hover { border-color: #3b82f6; }
.vote.voted { border-color: #3b82f6; background: rgba(96, 165, 250, .18); }
.vote-arrow { font-size: 11px; }
.net { font-size: 12px; color: var(--muted); }

.detail-board { margin-bottom: 20px; }
.tier-pool .badge { background: #394152; color: #dfe5f0; }

.comments h4 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.comment-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.comment-form input {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  min-width: 0;
}
.comment-form input::placeholder { color: var(--muted); }
.comment-form input:focus { border-color: var(--accent); }

#comment-author { width: 110px; }
#comment-text { flex: 1; min-width: 160px; }

.comments-list { display: grid; gap: 10px; }

.comment {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.comment-head { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.comment-text { font-size: 13px; line-height: 1.45; }

.upload-panel { width: min(420px, 100%); }

.upload-form { display: grid; gap: 12px; margin-top: 8px; }

.upload-form label {
  font-size: 13px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.upload-form input {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
.upload-form input:focus { border-color: var(--accent); }
.upload-form button { justify-self: start; }

.footer {
  border-top: 1px solid var(--border);
  padding: 18px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.footer a { color: var(--muted); text-decoration: none; font-weight: 600; }
.footer a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 16px; }
  .list-name { max-width: none; }
  .actions { justify-content: flex-end; }
  .search-wrap, main { padding-left: 16px; padding-right: 16px; }
  .tier { grid-template-columns: 44px 1fr; }
  .tier .badge { font-size: 20px; }
  .slot { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; padding: 10px; }
}