*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Space Grotesk", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at 12% 20%, rgba(0, 255, 255, 0.18), transparent 32%),
    radial-gradient(circle at 82% 12%, rgba(255, 96, 214, 0.2), transparent 35%),
    radial-gradient(circle at 60% 78%, rgba(96, 123, 255, 0.2), transparent 38%),
    #05060a;
  color: #f6f7fb;
  min-height: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 80px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  position: relative;
}

.app {
  width: 100%;
  max-width: 1100px;
  padding: 28px 18px 44px;
  position: relative;
  z-index: 1;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(6, 6, 12, 0.75);
  border: 1px solid rgba(0, 255, 255, 0.12);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-circle {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #00f6ff, #8f5bff);
  box-shadow: 0 10px 30px rgba(0, 255, 255, 0.35), 0 0 0 1px #7a5bff44;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: #c9c9c9;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-main {
  display: grid;
  gap: 16px;
}

.card {
  background: linear-gradient(160deg, rgba(12, 14, 28, 0.9), rgba(10, 8, 20, 0.94));
  border-radius: 18px;
  padding: 18px 20px 20px;
  box-shadow: 0 12px 46px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  border: 1px solid rgba(0, 255, 255, 0.1);
  backdrop-filter: blur(14px);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.muted {
  color: #cdd3dd;
  font-size: 0.85rem;
}

.status-text {
  font-size: 0.9rem;
}

.status-text.error {
  color: #ff4d4d;
}

.status-text.success {
  color: #1db954;
}

.btn {
  border-radius: 999px;
  border: none;
  padding: 7px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease,
    color 0.12s ease, filter 0.12s ease;
}

.btn.primary {
  background: linear-gradient(135deg, #ff5ef4 0%, #00f6ff 100%);
  color: #041015;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.7), 0 0 0 1px #00f6ff55, 0 0 20px #00f6ff44;
}

.btn.primary:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #ff73ff 0%, #4dfffc 100%);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.78), 0 0 0 1px #4dfffc55, 0 0 26px #4dfffc55;
  filter: drop-shadow(0 0 12px rgba(77, 255, 252, 0.35));
}

.btn.primary:active {
  transform: translateY(0);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.72);
}

.btn.subtle {
  background: rgba(255, 255, 255, 0.04);
  color: #f5f5f5;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn.subtle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.hidden {
  display: none !important;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
}

input[type="file"] {
  color: #f5f5f5;
  font-size: 0.85rem;
}

input[type="file"]::file-selector-button {
  border-radius: 999px;
  border: none;
  padding: 6px 14px;
  margin-right: 10px;
  background: linear-gradient(135deg, #ff5ef4 0%, #00f6ff 100%);
  color: #041015;
  cursor: pointer;
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0 8px;
}

textarea {
  width: 100%;
  margin-top: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 10, 16, 0.65);
  padding: 8px 10px;
  color: #f5f5f5;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: #1db954cc;
  box-shadow: 0 0 0 1px #1db954aa;
}

#matching-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.matching-threshold {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 0.8rem;
}

.matching-threshold-input {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.matching-threshold input[type="number"] {
  width: 60px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 10, 16, 0.7);
  color: #f5f5f5;
  padding: 3px 8px;
  font-size: 0.8rem;
}

.table-wrapper {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(6, 8, 16, 0.7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 255, 255, 0.06);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 0;
  font-size: 0.8rem;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(0, 255, 255, 0.1);
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th,
td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}

tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

tbody tr.missing td {
  color: #c0c0c0;
  font-style: italic;
}

tbody tr.missing td:nth-child(4),
tbody tr.missing td:nth-child(5),
tbody tr.missing td:nth-child(6) {
  color: #ff4d4d;
}

.confidence-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.confidence-badge.high {
  background: linear-gradient(135deg, #00f6ff, #6c7bff);
  color: #031018;
  box-shadow: 0 0 12px rgba(0, 246, 255, 0.35);
}

.confidence-badge.medium {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e2e2;
}

.confidence-badge.low {
  background: rgba(255, 255, 255, 0.04);
  color: #cfcfcf;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.playlist-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.playlist-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 4px;
}

.playlist-form input[type="text"] {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 10, 16, 0.65);
  padding: 6px 11px;
  color: #f5f5f5;
}

.playlist-form input[type="text"]:focus {
  outline: none;
  border-color: #1db954cc;
  box-shadow: 0 0 0 1px #1db95499;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* Query builder */
.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.year-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
}

.input-field input,
.input-field select {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 10, 16, 0.7);
  color: #f5f5f5;
  padding: 7px 10px;
}

.input-field input:focus,
.input-field select:focus {
  outline: none;
  border-color: #1db954cc;
  box-shadow: 0 0 0 1px #1db95499;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.output-box {
  background: rgba(6, 8, 16, 0.7);
  border: 1px solid rgba(0, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.output-label {
  font-size: 0.8rem;
  color: #cdd3dd;
  margin-bottom: 4px;
}

.output-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  word-break: break-word;
  white-space: pre-wrap;
}

.output-value.code {
  color: #e7f6ff;
}

.small-note {
  font-size: 0.8rem;
  margin-top: 6px;
}

.link-disabled {
  pointer-events: none;
  opacity: 0.6;
}

.subsection-title {
  margin: 20px 0 6px;
  font-size: 0.95rem;
  color: #e0e0e0;
}

.audio-features-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-inputs input[type="number"] {
  flex: 1;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 10, 16, 0.65);
  padding: 6px 10px;
  color: #f5f5f5;
  font-size: 0.85rem;
}

.range-inputs input[type="number"]:focus {
  outline: none;
  border-color: #1db954cc;
  box-shadow: 0 0 0 1px #1db95499;
}

.range-sep {
  color: #888;
  font-size: 0.9rem;
}

/* Sortable table headers */
.sortable-table th[data-sort] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.sortable-table th[data-sort]:hover {
  color: #00f6ff;
}

.sortable-table th[data-sort].sort-asc::after {
  content: " ▲";
  font-size: 0.65rem;
}

.sortable-table th[data-sort].sort-desc::after {
  content: " ▼";
  font-size: 0.65rem;
}

/* Track links - inherit color instead of blue */
.sortable-table td a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.3);
}

.sortable-table td a:hover {
  color: #00f6ff;
  text-decoration-color: #00f6ff;
}

/* Compact cells for audio features */
.sortable-table td {
  font-variant-numeric: tabular-nums;
}

.feature-cell {
  text-align: center;
  font-size: 0.8rem;
  color: #b0b0b0;
}

.app-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 0.8rem;
}

.app-footer code {
  padding: 2px 6px;
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    position: static;
    padding: 0;
    background: transparent;
    border: none;
  }

  .app {
    padding-inline: 10px;
  }

  .table-wrapper {
    overflow-x: auto;
  }
}


