/* SPECTRAL — dark glassmorphic semantic search UI */

:root {
  --bg: #0a0a0f;
  --bg-2: #0f0f18;
  --surface: rgba(255,255,255,0.04);
  --surface-2: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --text: #e8e6e3;
  --text-2: #a8a6a3;
  --muted: #6c6a67;
  --accent: #00ffa0;
  --accent-2: #ff5e9a;
  --accent-3: #5e9aff;
  --warn: #ffaa55;
  --danger: #ff4060;

  --r-release: #00ffa0;
  --r-artist: #ff5e9a;
  --r-video: #ffd055;
  --r-label: #5e9aff;
  --r-wiki: #c876ff;
  --r-sample: #ff8855;
  --r-tadb: #55c8ff;
  --r-allmusic: #ff5e9a;
  --r-lastfm: #ff4060;
  --r-genre: #88ff88;
  --r-review: #aaaaaa;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: radial-gradient(circle at top left, #1a0f25 0%, var(--bg) 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, "SF Pro Display", "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}
.logo {
  font-size: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}
h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  background: linear-gradient(90deg, #fff, #b8b8d4 70%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  margin: 2px 0 0 0;
  font-size: 11.5px;
  color: var(--text-2);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.stats {
  display: flex;
  gap: 24px;
  font-size: 11px;
  color: var(--text-2);
}
.stats .stat-item { text-align: right; }
.stats .stat-num {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  display: block;
}

/* ── SEARCH ZONE ── */
.search-zone {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 22px 18px;
  margin-bottom: 26px;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 50px -20px rgba(0,255,160,0.05);
}
.search-input-wrap {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
#q {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 18px;
  font-size: 16px;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#q:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,255,160,0.1);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #00cc88);
  color: #001a0f;
  border: none;
  padding: 0 28px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px -8px rgba(0,255,160,0.5);
}
.btn-primary:active { transform: translateY(0); }

/* mode toggle */
.mode-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-2);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-2);
  padding: 7px 14px;
  font-size: 12.5px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}
.mode-btn.active {
  background: var(--surface-2);
  color: var(--text);
}
.mode-btn:hover:not(.active) { color: var(--text); }

/* chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
  user-select: none;
}
.chip:hover { color: var(--text); border-color: var(--text-2); }
.chip.active {
  background: rgba(0,255,160,0.1);
  color: var(--accent);
  border-color: rgba(0,255,160,0.4);
}
.chip .ct {
  margin-left: 6px;
  opacity: 0.5;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

/* filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  font-size: 12px;
}
.filters label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
}
.filters input[type=text],
.filters input[type=number],
.filters select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  min-width: 80px;
  font-family: inherit;
}
.filters input:focus, .filters select:focus {
  border-color: var(--accent);
}
.pitch-label {
  cursor: pointer;
}
.pitch-label input[type=checkbox] { accent-color: var(--accent); }

/* ── STATUS ── */
.status {
  color: var(--text-2);
  font-size: 12px;
  margin-bottom: 14px;
  height: 18px;
  font-family: "SF Mono", monospace;
}
.status .timing {
  color: var(--muted);
  margin-left: 14px;
}

/* ── RESULTS ── */
main {
  display: grid;
  gap: 24px;
}
.table-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(16px);
  animation: fade-in 0.3s ease-out;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.table-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.table-header h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
}
.table-header .count {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.result-list { padding: 4px; }

.result-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  align-items: start;
}
.result-row:hover {
  background: var(--surface-2);
}
.result-dist {
  font-family: "SF Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-top: 3px;
}
.result-content { min-width: 0; }
.result-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.result-title .id-tag {
  font-family: "SF Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  background: var(--bg-2);
  padding: 2px 7px;
  border-radius: 4px;
}
.result-meta {
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.5;
}
.result-meta .tag {
  display: inline-block;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 100px;
  margin-right: 6px;
  font-size: 10.5px;
  color: var(--text-2);
}
.result-meta .preview {
  display: block;
  margin-top: 6px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 4.6em;
  overflow: hidden;
  -webkit-line-clamp: 3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}
.result-actions {
  display: flex;
  gap: 6px;
}
.action-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 4px 10px;
  font-size: 10.5px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.action-btn:hover {
  background: rgba(0,255,160,0.08);
  color: var(--accent);
  border-color: var(--accent);
}

/* color the left edge of result-block by table type */
.table-block.release { border-left: 3px solid var(--r-release); }
.table-block.artist { border-left: 3px solid var(--r-artist); }
.table-block.video { border-left: 3px solid var(--r-video); }
.table-block.label { border-left: 3px solid var(--r-label); }
.table-block.wikipedia, .table-block.release_wiki { border-left: 3px solid var(--r-wiki); }
.table-block.sample { border-left: 3px solid var(--r-sample); }
.table-block.tadb { border-left: 3px solid var(--r-tadb); }
.table-block.allmusic { border-left: 3px solid var(--r-allmusic); }
.table-block.lastfm { border-left: 3px solid var(--r-lastfm); }
.table-block.genre_wiki { border-left: 3px solid var(--r-genre); }
.table-block.review { border-left: 3px solid var(--r-review); }

/* spectral results */
.spectral-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  padding: 14px;
}
.spectral-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.spectral-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.spec-row {
  display: flex;
  gap: 14px;
  font-family: "SF Mono", monospace;
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.spec-bpm {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}
.spec-key { color: var(--accent-3); }
.spec-dance { color: var(--accent-2); }
.spec-vec { color: var(--warn); }
.spec-artist {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.spec-track {
  color: var(--text-2);
  font-size: 11.5px;
}
.spec-title {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

/* ── DRAWER ── */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 580px;
  max-width: 90vw;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  padding: 30px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(.16,1,.3,1);
  z-index: 100;
  box-shadow: -20px 0 60px rgba(0,0,0,0.5);
}
.drawer.open { transform: translateX(0); }
.drawer-close {
  position: absolute;
  top: 18px;
  right: 22px;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-2);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s;
}
.drawer-close:hover { background: var(--surface-2); color: var(--text); }
#drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}
#drawer-backdrop.show { opacity: 1; pointer-events: auto; }

/* drawer content */
.drawer h2 {
  font-size: 22px;
  margin: 0 0 4px;
  font-weight: 700;
}
.drawer h3 {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 24px 0 8px 0;
  font-weight: 600;
}
.drawer .ditem {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  font-size: 12.5px;
}
.drawer .ditem .small { color: var(--muted); font-size: 10.5px; margin-top: 3px; }
.drawer .pill {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 100px;
  margin: 0 6px 4px 0;
  font-size: 11px;
  color: var(--text);
}
.drawer .ext-link {
  display: inline-block;
  background: rgba(94,154,255,0.1);
  border: 1px solid rgba(94,154,255,0.3);
  color: var(--accent-3);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  margin: 2px;
  text-decoration: none;
  font-family: "SF Mono", monospace;
}
.drawer .ext-link:hover {
  background: rgba(94,154,255,0.2);
}
.drawer .biotext {
  background: var(--surface);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.drawer .biotext-title {
  color: var(--text-2);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

/* responsive */
@media (max-width: 800px) {
  .stats { display: none; }
  .filters { font-size: 11px; }
  .app { padding: 18px; }
  .drawer { width: 100%; }
}
