/* ── Tokens ── */
:root {
  --bg: #ffffff;
  --ink: #0a0a0a;
  --muted: #7a7a7a;
  --line: #e4e4e4;
  --hairline: #f0f0f0;
  --panel: #fafafa;
  --warn: #c94a2b;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
  --row-pad: 10px 12px;
  --accent: #0a0a0a;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
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 80px; }

.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-primary { background: var(--accent); color: var(--bg); border: none; padding: 10px 16px;
  font-size: 13px; width: 100%; }
.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn[disabled], .btn-primary[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ── Empty / Banner / Inline error ── */
.empty-state { padding-top: 80px; max-width: 540px; margin: 0 auto; text-align: center; }
.empty-h1 { font-size: 56px; font-weight: 700; letter-spacing: -1.6px; margin: 0; line-height: 1; }
.empty-hint { font-size: 15px; color: var(--muted); margin-top: 14px; line-height: 1.55; }
.empty-form { margin-top: 32px; display: flex; gap: 8px; justify-content: center; }
.empty-form input[type=file] { font-family: var(--font); font-size: 14px;
  padding: 10px 12px; border: 1px solid var(--line); outline: none; }
.empty-form input[type=file]:focus { border-color: var(--ink); }

.inline-error { margin-top: 24px; padding: 10px 14px;
  background: #fef3f1; border: 1px solid var(--warn);
  color: var(--warn); font-size: 13px; font-family: var(--mono); text-align: left; }

.dropzone-active { outline: 4px solid var(--ink); outline-offset: -4px; }

.dropzone-box { margin-top: 32px; padding: 32px 24px; border: 2px dashed #d4d4d4;
  border-radius: 12px; color: var(--muted); font-size: 15px; text-align: center; }
.browse-btn { font: inherit; color: var(--ink); background: transparent;
  border: 1px solid var(--ink); padding: 4px 12px; border-radius: 6px; cursor: pointer; }
.browse-btn:hover { background: var(--ink); color: var(--bg); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Section heads ── */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--ink); font-weight: 600; }

/* ── Settings panel (right side of "uploaded") ── */
.seeds-panel { border: 1px solid var(--line); padding: 16px; }
.opt-block { margin-bottom: 18px; }
.opt-block:last-child { margin-bottom: 0; }
.opt-block label.row { display: block; padding: 6px 0; cursor: pointer; }
.opt-block label.row input { margin-right: 8px; }
.opt-row-desc { display: block; margin-left: 22px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.opt-search input { width: 100%; padding: 6px 10px; border: 1px solid var(--line);
  font-family: var(--font); font-size: 13px; outline: none; }
.opt-track-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--hairline); margin-top: 6px; }
.opt-track-row { padding: 6px 10px; cursor: pointer; font-size: 12px; border-bottom: 1px solid var(--hairline); }
.opt-track-row:hover { background: var(--panel); }
.opt-track-row.selected { background: var(--ink); color: var(--bg); }

/* ── Tables ── */
.results-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.results-table thead tr { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.results-table th { text-align: left; padding: 8px 10px; font-weight: 500; }
.results-table tbody tr { border-bottom: 1px solid var(--hairline); cursor: default; }
.results-table tbody tr:hover { background: var(--panel); }
.results-table .col-rank { color: var(--muted); font-variant-numeric: tabular-nums;
  font-family: var(--mono); font-size: 11px; width: 2.75rem; }
.results-table .col-name { font-weight: 500; font-size: 14px;
  width: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results-table .col-artist { color: var(--muted); font-size: 12px;
  width: 35%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results-table .col-album { color: var(--muted); font-size: 12px;
  width: 28%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results-table .col-time { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.results-table .col-score { font-family: var(--mono); font-size: 11px; color: var(--muted);
  width: 5.5rem; text-align: right; padding-right: 14px; }

.scroll-360 { max-height: 360px; overflow: hidden auto; }
.scroll-520 { max-height: 520px; overflow: hidden auto; }

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

/* ── Hover/expanded details on done view ── */
.track-details-panel { margin-top: 24px; padding: 18px 20px;
  border-top: 1px solid var(--ink); background: var(--panel); }
.track-details-panel-empty { background: transparent; border-top: 1px solid var(--hairline); }
.track-details-header { display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--hairline); }
.track-details-name { font-size: 16px; font-weight: 500; letter-spacing: -0.2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-details-artist { color: var(--muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-table { width: 100%; table-layout: fixed; font-size: 13px; border-collapse: collapse; }
.breakdown-table th { text-align: left; padding: 4px 8px; font-size: 10px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--ink); }
.breakdown-table td { padding: 6px 8px; border-bottom: 1px solid var(--hairline);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-table th:nth-child(2), .breakdown-table td:nth-child(2) { width: 32%; }
.breakdown-table .mono { width: 5rem; }
.breakdown-table td.mono { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag-chip { font-size: 11px; padding: 3px 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--muted); font-family: var(--font); }

/* ── Bottom actions ── */
.bottom-row { display: flex; gap: 8px; margin-top: 24px; align-items: center; }
.bottom-row .bottom-row-gap { margin-left: 16px; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .app-shell { padding: 0 16px 40px; }
  .gathering-panel { padding: 16px; }

  .results-table thead { display: none; }
  .results-table tbody tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 10px;
    row-gap: 2px;
    align-items: baseline;
    border: 1px solid var(--line);
    margin-bottom: 6px;
    padding: 10px 12px;
  }
  .results-table td {
    padding: 0;
    border: none;
    min-width: 0;
    width: auto;
  }
  .results-table .col-rank {
    grid-row: 1 / -1;
    align-self: center;
    width: auto;
    font-size: 13px;
    padding-right: 4px;
  }
  .results-table .col-name {
    grid-row: 1;
    grid-column: 2;
    width: auto;
    font-size: 15px;
  }
  .results-table .col-score {
    grid-row: 1;
    grid-column: 3;
    width: auto;
    padding-right: 0;
    font-size: 12px;
  }
  .results-table .col-artist {
    grid-row: 2;
    grid-column: 2 / -1;
    width: auto;
    font-size: 13px;
  }
  .results-table .col-album {
    grid-row: 3;
    grid-column: 2 / -1;
    width: auto;
  }
}

/* ── Action strip (uploaded screen) ── */
.action-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 24px 0 0;
}
.action-strip .btn-primary { width: auto; min-width: 240px; }
.btn-link {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 8px;
  cursor: pointer;
}
.btn-link:hover { color: var(--ink); }
.action-strip + .seeds-panel { margin-top: 20px; }

/* ── Help icon + modal ── */
.help-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  margin: 0 4px;
  padding: 0;
  font-family: var(--font); font-size: 11px; font-weight: 600; line-height: 1;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 50%;
  cursor: pointer; vertical-align: baseline;
}
.help-icon:hover { background: var(--ink); color: var(--bg); }

.help-modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(10, 10, 10, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.help-modal {
  position: relative;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--ink);
  padding: 28px 32px;
  max-width: 520px; width: 100%;
  max-height: calc(100vh - 48px); overflow-y: auto;
  font-size: 14px; line-height: 1.55;
}
.help-modal h2 {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  font-weight: 600; color: var(--ink);
  margin: 0 0 12px;
}
.help-modal h2 + ol { margin-top: 0; }
.help-modal ol { margin: 0 0 24px; padding-left: 20px; }
.help-modal ol:last-child { margin-bottom: 0; }
.help-modal li { margin-bottom: 6px; }
.help-modal-close {
  position: absolute; top: 8px; right: 12px;
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--muted);
  padding: 4px 8px;
}
.help-modal-close:hover { color: var(--ink); }

@media (max-width: 768px) {
  .help-modal-backdrop { padding: 12px; }
  .help-modal { padding: 20px 18px; }
}

.tag-section { margin-top: 14px; }
.tag-section-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px; }

/* ── Warning sections (NotFound / Unmatched) ── */
.warning-section { margin-top: 24px; padding: 12px 16px;
  background: #fff7e6; border: 1px solid #f0b656; border-radius: 6px;
  font-size: 13px; color: var(--ink); }
.warning-section .warning-title { font-weight: 600; margin-bottom: 6px; }
.warning-section .warning-list { margin: 6px 0 0; padding-left: 18px; }
.warning-section .warning-list li { margin: 2px 0; }
.warning-section .warning-list .mono { font-family: var(--mono); }
.warning-section.neutral { background: var(--panel); border-color: var(--line); color: var(--muted); }
