/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #111112;
  --surface:  #1a1a1b;
  --surface2: #222224;
  --border:   #2c2c2e;
  --border2:  #383838;
  --text:     #d0d0d2;
  --text-dim: #6a6a70;
  --text-mid: #999;
  --accent:   #4f8ec9;
  --accent-h: #6aa3d8;
  --green:    #4aad6a;
  --yellow:   #c8973e;
  --red:      #c05858;
  --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:     ui-monospace, 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --radius:   4px;
}

html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  max-width: 1100px;
  margin: 0;
  padding-left: 0;
}
.logo {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.tagline {
  color: var(--text-dim);
  font-size: 12px;
}


/* ── Error banner ──────────────────────────────────────────────────────────── */
.error-banner {
  background: #2e1616;
  border-bottom: 1px solid #5c2a2a;
  color: #df8080;
  font-size: 13px;
  padding: 10px 24px;
}

/* ── Search ────────────────────────────────────────────────────────────────── */
.search-section {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 20px;
}
.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search-row input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  padding: 9px 13px;
  transition: border-color .15s;
}
.search-row input:focus { border-color: var(--accent); }
.search-row input::placeholder { color: var(--text-dim); }

.search-row button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 22px;
  transition: background .15s;
  white-space: nowrap;
}
.search-row button:hover { background: var(--accent-h); }
.search-row button:disabled {
  background: var(--surface2);
  color: var(--text-dim);
  cursor: default;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-row label {
  color: var(--text-dim);
  font-size: 12px;
}
.filter-row select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
}

/* ── Loading ───────────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 24px;
  justify-content: center;
}
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results ───────────────────────────────────────────────────────────────── */
#results-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 120px;
}

.results-meta {
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .6px;
  padding: 7px 10px;
  text-align: left;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
thead th[data-sort] { cursor: pointer; }
thead th[data-sort]:hover { color: var(--text-mid); }
thead th.sort-asc::after  { content: ' ▲'; font-size: 9px; }
thead th.sort-desc::after { content: ' ▼'; font-size: 9px; }

tbody tr:hover td { background: var(--surface); }

td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}

/* column widths */
.col-name { width: 38%; white-space: normal; }
.col-fmt  { width: 52px; }
.col-br   { width: 80px; }
.col-dur  { width: 64px; }
.col-sz   { width: 72px; }
.col-usr  { width: 13%; }
.col-act  { width: 1%; }

.cell-name {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-word;
  line-height: 1.4;
}

.fmt-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--border2);
  color: var(--text-dim);
  text-transform: uppercase;
}
.fmt-mp3  { color: #4f8ec9; border-color: #4f8ec940; }
.fmt-flac { color: #4aad6a; border-color: #4aad6a40; }
.fmt-wav  { color: #c8973e; border-color: #c8973e40; }
.fmt-opus { color: #9b7ec8; border-color: #9b7ec840; }
.fmt-ogg  { color: #9b7ec8; border-color: #9b7ec840; }

.cell-dim {
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono);
}

.cell-user {
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--mono);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 10px;
  transition: border-color .12s, color .12s, background .12s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
  color: var(--text-dim);
}
.btn:hover {
  border-color: var(--border2);
  color: var(--text);
  background: var(--surface2);
}

.btn-preview {
  color: var(--green);
  border-color: #4aad6a35;
}
.btn-preview:hover {
  background: #4aad6a18;
  border-color: var(--green);
  color: var(--green);
}
.btn-preview.loading-btn {
  cursor: wait;
  opacity: .6;
}

.btn-dl {
  color: var(--accent);
  border-color: #4f8ec935;
}
.btn-dl:hover {
  background: #4f8ec918;
  border-color: var(--accent);
  color: var(--accent);
}
.btn-dl.queued {
  color: var(--text-dim);
  pointer-events: none;
}

.btn-save {
  color: var(--text-mid);
  border-color: var(--border2);
  font-size: 12px;
  padding: 4px 10px;
}
.btn-save:hover {
  color: var(--text);
  border-color: var(--border2);
  background: var(--surface2);
}

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  color: var(--text-dim);
  font-size: 14px;
  padding: 60px 24px;
  text-align: center;
}

/* ── Player ────────────────────────────────────────────────────────────────── */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0d0d0e;
  border-top: 1px solid var(--border2);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 200;
}

.player-left {
  min-width: 0;
  width: 220px;
  flex-shrink: 0;
}
.player-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.player-user {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-center {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-status {
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}

audio {
  width: 100%;
  min-width: 160px;
  max-width: 600px;
  height: 30px;
  accent-color: var(--accent);
}

.player-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 6px;
  border-radius: var(--radius);
}
.btn-icon:hover {
  color: var(--text);
  background: var(--surface2);
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }
