/* Tokens follow music-sorter's palette so the four music tools read as one set.
   Nothing in this file may cap a height or create a vertical scroller: the blog
   wrapper measures the iframe's own document, and a nested scroller is invisible
   to it. Horizontal scrolling on the table wrapper is fine and intended. */
:root {
  --bg: #ffffff;
  --ink: #0a0a0a;
  --muted: #7a7a7a;
  --faint: #a8a8a8;
  --line: #e4e4e4;
  --hairline: #f0f0f0;
  --panel: #fafafa;
  --warn: #c94a2b;
  --accent: #0a0a0a;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 14px; line-height: 1.55;
}

.app-shell { max-width: 1280px; margin: 0 auto; padding: 0 24px 64px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Buttons ── */
.btn {
  font-family: var(--font); font-size: 12px; padding: 6px 12px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--ink); cursor: pointer;
}
.btn:hover { background: var(--panel); }
.btn-primary {
  background: var(--accent); color: var(--bg); border: none;
  padding: 10px 18px; font-size: 13px;
}
.btn[disabled], .btn-primary[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-link {
  font: inherit; background: none; border: none; padding: 0;
  color: var(--ink); text-decoration: underline; cursor: pointer;
}

/* ── Form ── */
.intro { padding-top: 40px; max-width: 640px; }
.intro h1 { font-size: 40px; font-weight: 700; letter-spacing: -1px; margin: 0 0 8px; }
.intro p { color: var(--muted); margin: 0 0 24px; }

.group-form { max-width: 640px; }
.group-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.group-row input[type=text] {
  flex: 1 1 auto; padding: 8px 10px; font: inherit;
  border: 1px solid var(--line); outline: none;
}
.group-row input[type=text]:focus { border-color: var(--ink); }
.group-row select { padding: 8px 6px; font: inherit; border: 1px solid var(--line); }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 12px; }

.inline-error {
  margin: 20px 0; padding: 10px 14px;
  background: #fef3f1; border: 1px solid var(--warn);
  color: var(--warn); font-size: 13px; font-family: var(--mono);
}
.inline-error ul { margin: 6px 0 0; padding-left: 18px; }

/* ── Waiting view ── */
.progress-panel { border: 1px solid var(--ink); padding: 24px 28px; margin: 32px 0; }
.progress-head {
  display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px;
}
.progress-label { font-size: 14px; font-weight: 500; }
.progress-counter { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.progress-track { height: 4px; background: var(--hairline); margin-bottom: 18px; }
.progress-fill { height: 100%; background: var(--ink); transition: width 200ms ease; }
.progress-queue { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

/* ── Controls ── */
.controls {
  display: flex; flex-wrap: wrap; gap: 24px;
  border: 1px solid var(--line); padding: 16px; margin: 24px 0;
}
.control-block { min-width: 220px; }
.control-label {
  display: block; font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--ink); font-weight: 600; margin-bottom: 6px;
}
.control-value { font-size: 12px; color: var(--muted); margin-top: 4px; }
.control-block input[type=range] { width: 100%; }
.weights-list { display: flex; flex-wrap: wrap; gap: 12px; }
.weight-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.weight-item input[type=number] { width: 64px; padding: 4px 6px; font: inherit; border: 1px solid var(--line); }
.weight-item input[readonly] { background: var(--hairline); color: var(--faint); }
.weight-reason { font-size: 11px; color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.chip {
  font: inherit; font-size: 11px; padding: 3px 9px; cursor: pointer;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-count { color: var(--faint); margin-left: 4px; }
.chip[aria-pressed="true"] .chip-count { color: var(--line); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
.results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results-table thead tr { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.results-table th { text-align: left; padding: 8px 10px; font-weight: 500; white-space: nowrap; }
.results-table th button {
  font: inherit; font-weight: 500; background: none; border: none; padding: 0;
  cursor: pointer; color: var(--ink);
}
.results-table th[aria-sort] button { text-decoration: underline; }
.results-table tbody tr { border-bottom: 1px solid var(--hairline); }
.results-table tbody tr:hover { background: var(--panel); }
.col-rank { color: var(--muted); font-family: var(--mono); font-size: 11px; width: 4rem; }
.col-artist { font-weight: 500; font-size: 14px; }
.col-tags { color: var(--muted); font-size: 11px; }
.col-cov { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.col-user { font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.col-user .pred { color: var(--faint); margin-left: 6px; }
.col-user.backfilled { font-style: italic; }
.col-score { font-family: var(--mono); font-size: 12px; position: relative; width: 5rem; }
.score-bar { display: block; height: 3px; background: var(--ink); margin-top: 3px; }
.expand-btn {
  font: inherit; background: none; border: 1px solid var(--line);
  width: 20px; height: 20px; line-height: 1; cursor: pointer; color: var(--muted);
}
.tag-skeleton { display: inline-block; width: 60px; height: 8px; background: var(--hairline); }

.details-row td { background: var(--panel); padding: 12px 14px; }
.details-user { margin-bottom: 10px; }
.details-user-name { font-weight: 500; font-size: 12px; }
.details-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.details-table th {
  text-align: left; padding: 3px 8px; font-size: 10px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.details-table td { padding: 4px 8px; border-bottom: 1px solid var(--hairline); }
.details-table td.num { font-family: var(--mono); text-align: right; color: var(--muted); }

.result-foot { font-size: 11px; color: var(--faint); margin-top: 16px; font-family: var(--mono); }

/* ── Narrow viewports: a restyle of the same markup, not a second renderer ── */
@media (max-width: 720px) {
  .results-table thead { display: none; }
  .results-table, .results-table tbody, .results-table tr, .results-table td { display: block; width: 100%; }
  .results-table tbody tr { border: 1px solid var(--line); margin-bottom: 8px; padding: 8px 10px; }
  .results-table td { border: none; padding: 2px 0; }
  .results-table td[data-label]::before {
    content: attr(data-label) " ";
    font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
  }
  .table-wrap { overflow-x: visible; }
}
