/* shrike — lime on dark slate. One accent, one job per color. */

:root {
  --bg: #101410;
  --bg-panel: #161c16;
  --bg-raise: #1d241d;
  --line: #2a332a;
  --text: #d6ddd2;
  /* #8a9784, not #7d8a78: the old value measured 4.37:1 on --bg-raise —
     below AA for the 10-12px labels it paints (re-measured 2026-09-21). */
  --text-dim: #8a9784;
  --lime: #a4d233;
  --lime-dim: #6f9422;
/* Ink variant of the lime: identical in the dark skin; the classic skin
     darkens it, because #A4D233 text on grey fails contrast (measured). */
  --lime-ink: #a4d233;
  --err: #e05555;
  --warn: #e0a832;
  /* Stage palette — one hue per pipeline stage (spec: enqueued gray,
     downloading teal, converting purple, importing amber, landed lime).
     Used by transfer row borders/dots and the segment tints. */
  --stage-enqueued: #8a9784;
  --stage-downloading: #40c8be;
  --stage-converting: #aa78ff;
  --stage-importing: #e0a832;
  --stage-landed: #a4d233;
  --stage-downloading-tint: rgba(64, 200, 190, 0.5);
  --stage-converting-tint: rgba(170, 120, 255, 0.5);
  --stage-importing-tint: rgba(224, 168, 50, 0.55);
  --chip-qobuz: #2f9e8f;
  --chip-tidal: #33a3ff;
  --chip-deezer: #a238ff;
}

  /* ── toast (grab confirmation; see app.js showToast) ────── */
#toast {
  position: fixed; left: 50%; bottom: 46px; transform: translate(-50%, 8px);
  background: var(--bg-raise); color: var(--text); border: 1px solid var(--line);
  border-radius: 4px; padding: 8px 14px; font-size: 13px; z-index: 150;
  max-width: min(90vw, 560px); text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast.clickable { cursor: pointer; }
#toast.clickable:hover { border-color: var(--lime-ink); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}

/* ── splash ─────────────────────────────────────────────── */
#splash {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; cursor: pointer;
  transition: opacity .3s;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-icon { width: 72px; height: 72px; }
.splash-mark { font-size: 42px; font-weight: 800; letter-spacing: -1px; color: var(--text); }
.splash-mark span { color: var(--lime-ink); }
.splash-status { color: var(--text-dim); font-size: 13px; }

/* ── header ─────────────────────────────────────────────── */
#app-header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
}
.hdr-slot { flex: 1 1 0; min-width: 0; }
.hdr-right { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.wordmark { font-weight: 800; font-size: 20px; letter-spacing: -0.5px; white-space: nowrap; }
.wordmark span { color: var(--lime-ink); }
.wordmark-icon { width: 22px; height: 22px; vertical-align: -4px; margin-right: 2px; }
#search-form { flex: 0 1 640px; display: flex; gap: 8px; margin: 0; }
#search-input {
  flex: 1; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  color: var(--text); font-size: 14px;
}
#search-input:focus { border-color: var(--lime-dim); }
#conn-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); }
.status-dot.ok { background: var(--lime); }
.status-dot.bad { background: var(--err); }

/* ── tab strip ──────────────────────────────────────────── */
#tab-strip {
  display: flex; gap: 2px; padding: 6px 16px 0;
  background: var(--bg-panel); border-bottom: 1px solid var(--line);
}
.tab {
  appearance: none; border: 1px solid var(--line); border-bottom: none;
  background: var(--bg); color: var(--text-dim);
  padding: 7px 18px 8px; font-size: 13px; cursor: pointer;
  border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--bg-panel); color: var(--lime-ink);
  border-color: var(--lime-ink);
  position: relative; top: 1px;
}

/* ── panels ─────────────────────────────────────────────── */
#panels { flex: 1; overflow: hidden; position: relative; }
.panel { display: none; position: absolute; inset: 0; overflow: auto; padding: 16px; }
.panel.active { display: block; }

/* ── search tab ─────────────────────────────────────────── */
.search-controls, .tf-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.type-tabs, .tf-filters { display: flex; gap: 2px; }
.type-tab {
  appearance: none; border: 1px solid var(--line); background: var(--bg);
  color: var(--text-dim); padding: 5px 14px; font-size: 12px; cursor: pointer;
  border-radius: 12px;
}
.type-tab.active { color: var(--lime-ink); border-color: var(--lime-ink); background: var(--bg-raise); }
.sort-label { margin-left: auto; font-size: 12px; color: var(--text-dim); display: flex; gap: 6px; align-items: center; }
#search-sort, #search-quality { background: var(--bg-raise); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; font-size: 12px; }

.result-row,
.tf-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  margin-bottom: 6px; background: var(--bg-panel);
}
.result-row:hover { border-color: var(--lime-dim); }
.cover { width: 44px; height: 44px; border-radius: 4px; object-fit: cover; flex: none; }
.cover-empty { background: var(--bg-raise); border: 1px dashed var(--line); }
.result-main, .tf-main { flex: 1; min-width: 0; }
.result-title, .tf-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quality-label { font-size: 12px; color: var(--text-dim); display: flex; flex-direction: column; gap: 2px; }
/* S5 source toggle: Soulseek is opt-in, so the control has to be visible. */
.slsk-toggle {
  font-size: 12px; color: var(--text-dim); display: flex; gap: 6px;
  align-items: center; cursor: pointer;
}
.slsk-toggle input { accent-color: var(--lime-ink); margin: 0; }
/* result kind tag (album/artist/playlist/track) on the provider row */
.result-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; }

.result-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* Quality badge on the right */
.qual-badge { font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 600; letter-spacing: 0.5px; }
.qual-badge.qual-hi-res { background: rgba(164, 210, 51, 0.3); color: var(--lime-ink); border: 1px solid var(--lime-dim); }
.qual-badge.qual-lossless { background: rgba(164, 210, 51, 0.2); color: var(--lime-ink); }
.qual-badge.qual-opus { background: rgba(51, 163, 255, 0.15); color: #5bb3ff; }
.qual-badge.qual-aac { background: rgba(51, 163, 255, 0.1); color: var(--text); }
.qual-badge.qual-ogg { background: rgba(224, 168, 50, 0.1); color: var(--warn); }
.qual-badge.qual-wma { background: rgba(150, 150, 150, 0.1); color: var(--text-dim); }
.qual-badge.qual-mp3 { background: rgba(150, 150, 150, 0.08); color: var(--text-dim); }
.btn-dl, .lib-format { flex: none; }
.lane-select { flex: none; background: var(--bg-raise); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; font-size: 12px; cursor: pointer; }

/* ── P2P album groups (Soulseek track matches grouped by album) ── */
.p2p-section { margin-top: 1rem; }
.p2p-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
}
/* INSPECT panel: the peer folder's real file list, expanded in place. */
.p2p-inspect {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
}
.p2p-inspect[disabled] { opacity: 0.6; }
.p2p-inspect-panel {
  border-top: 1px dashed var(--line);
  margin: 0 0.75rem 0.6rem;
  padding: 0.4rem 0.2rem 0.2rem;
  font-size: 0.78rem;
}
.p2p-inspect-row { display: flex; align-items: center; }
.p2p-inspect-check { accent-color: var(--lime); width: 15px; height: 15px; margin-right: 8px; flex: none; }
.p2p-inspect-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 0.4rem; }
.p2p-inspect-hint { color: var(--text-dim); font-size: 0.72rem; }
.p2p-cover {
  width: 44px; height: 44px; object-fit: cover;
  border: 1px solid var(--line); border-radius: 3px; flex: none;
  align-self: center;
}
.p2p-inspect-head { color: var(--text-dim); margin-bottom: 0.35rem; }
.p2p-inspect-row { padding: 2px 0; }
.p2p-inspect-row .p2p-inspect-meta { margin-left: auto; }
.p2p-inspect-name { color: var(--text); overflow-wrap: anywhere; }
.p2p-inspect-meta { color: var(--text-dim); white-space: nowrap; }
.p2p-inspect-err { color: var(--text-dim); font-style: italic; }

/* Soulseek album-hunter filters (P1). One row of controls above the copies;
   counts stay honest: the summary line reports what is visible AND what the
   filters hid. */
.p2p-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.p2p-f-label { display: inline-flex; align-items: center; gap: 6px; }
.p2p-f-label select {
  background: var(--bg-raise);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 3px 6px;
  font-size: 16px;            /* stop iOS zoom-on-focus (mobile pass rule) */
}
.p2p-check { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.p2p-check input { accent-color: var(--lime); width: 15px; height: 15px; }
.p2p-clear {
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 0.78rem;
  padding: 4px 8px;
  cursor: pointer;
}
.p2p-clear:hover { color: var(--text); border-color: var(--lime); }
.p2p-album-group {
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  background: var(--bg-raise);
}
.p2p-album-group summary {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  list-style: none;
}
.p2p-album-group summary::-webkit-details-marker { display: none; }
.p2p-album-group summary::before {
  content: '▶';
  font-size: 0.7rem;
  color: var(--text-dim);
  transition: transform 0.15s;
}
.p2p-album-group[open] summary::before { transform: rotate(90deg); }
.p2p-album-title { font-weight: 600; color: var(--lime-ink); }
.p2p-meta { font-size: 0.8rem; color: var(--text-dim); }
.p2p-track-list {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--line);
}
.p2p-track {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.85rem;
}
.p2p-track-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p2p-peer {
  flex: none;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
}
.p2p-dl-album { margin: 0 0.75rem 0.5rem; }
.p2p-partial,
.p2p-fit-bad {
  flex: none;
  font-size: 0.7rem;
  color: var(--err);
  border: 1px solid var(--err);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  margin-left: 0.25rem;
}
/* Duration-fit: the peer's declared length vs the MusicBrainz expectation.
   Advisory — a mismatch warns about a preview/truncated copy the organizer's
   gate would refuse after the download; it never blocks the grab button. */
.p2p-fit-ok {
  flex: none;
  font-size: 0.7rem;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  margin-left: 0.25rem;
}
/* Known-bad source (lane blocklist): the organizer quarantined a release from
   this peer dir. Louder than the fit warning — the lane refuses the grab, so
   the copy's button is disabled, not merely discouraged. */
.p2p-blocked {
  flex: none;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--err);
  border: 1px solid var(--err);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  margin-left: 0.25rem;
}
.p2p-dur {
  flex: none;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.p2p-dur-bad { color: var(--err); }
/* Track tab: one row per unique track; peer copies live in the expander. */
.p2p-track-group {
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 0.4rem;
  background: var(--bg-raise);
}
.p2p-track-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
}
.p2p-copies {
  border-top: 1px solid var(--line);
}
.p2p-copies summary {
  cursor: pointer;
  list-style: none;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.p2p-copies summary::-webkit-details-marker { display: none; }
.p2p-copies summary::before { content: '▸ '; color: var(--text-dim); }
.p2p-copies[open] summary::before { content: '▾ '; }
.p2p-copy-list { padding: 0.25rem 0.75rem 0.5rem; }
.p2p-copy-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.85rem;
}
.btn-mini { padding: 0.1rem 0.5rem; font-size: 0.75rem; }
.dl-chip { font-size: 11px; padding: 1px 8px; border-radius: 3px; margin-left: 8px; }
.dl-chip.ok { background: rgba(164, 210, 51, 0.15); color: var(--lime-ink); }
.dl-chip.err { background: rgba(224, 85, 85, 0.12); color: var(--err); }

/* ── transfers tab ──────────────────────────────────────── */
.tf-meta, .tf-sub { font-size: 12px; color: var(--text-dim); }
.tf-fleet-actions, .fleet-actions { margin-left: auto; display: flex; gap: 6px; }

/* Landed flash — the row leaves a beat after it completes (transfers.js). */
.tf-row.tf-landed { animation: tf-landed 4s ease forwards; }
@keyframes tf-landed {
  0% { background: rgba(164, 210, 51, 0.22); }
  60% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tf-row.tf-landed { animation: none; opacity: 0; }
}
/* Row state signal: colored left border + status dot, keyed off the data-stage
   the renderer already emits (no per-status rule for every new state). */
.tf-row { border-left: 3px solid var(--line); }
.tf-row[data-stage="enqueued"] { border-left-color: var(--stage-enqueued); }
.tf-row[data-stage="downloading"] { border-left-color: var(--stage-downloading); }
.tf-row[data-stage="converting"] { border-left-color: var(--stage-converting); }
.tf-row[data-stage="importing"] { border-left-color: var(--stage-importing); }
.tf-row[data-stage="landed"] { border-left-color: var(--stage-landed); }
.tf-row.status-failed { border-left-color: var(--err); }
.tf-row::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--text-dim); }
.tf-row[data-stage="landed"]::before { background: var(--stage-landed); }
.tf-row.status-failed::before { background: var(--err); }
.tf-err { color: var(--err); margin-left: 6px; }
.tf-bar-cell { flex: 0 0 240px; }
.tf-stage { font-size: 10px; letter-spacing: 0.8px; color: var(--text-dim); margin-top: 3px; text-transform: uppercase; }
.tf-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

.chunked-bar {
  position: relative; height: 14px; border-radius: 3px;
  background: var(--bg); border: 1px solid var(--line); overflow: hidden;
}
.chunked-bar .fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--lime-dim), var(--lime));
  transition: width .4s;
}
.chunked-bar .segs { position: absolute; inset: 0; display: flex; }
.chunked-bar .seg { flex: 1; border-right: 2px solid var(--bg-panel); }
.chunked-bar .seg:last-child { border-right: none; }
.chunked-bar .seg.done { background: rgba(164, 210, 51, 0.25); }
.chunked-bar .seg.cur { background: rgba(164, 210, 51, 0.45); }
.chunked-bar .seg.fail { background: rgba(224, 85, 85, 0.45); }
.chunked-bar .seg.cancelled { background: rgba(125, 138, 120, 0.3); }
/* Stage tint: the current segment's hue marks the pipeline stage. */
.tf-row[data-stage="downloading"] .seg.cur,
.tr-run { background: var(--stage-downloading-tint); }
.tf-row[data-stage="converting"] .seg.cur { background: var(--stage-converting-tint); }
.tf-row[data-stage="importing"] .seg.cur { background: var(--stage-importing-tint); }
.chunked-bar.pulse .fill { animation: tf-pulse 1.4s ease-in-out infinite; }
@keyframes tf-pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

.tf-truncated {
  font-size: 12px; color: var(--text-dim); padding: 6px 10px;
  border: 1px dashed var(--line); border-radius: 6px; margin-bottom: 8px;
}

/* ── library tab ────────────────────────────────────────── */
.lib-layout { display: flex; gap: 0; height: 100%; min-height: 0; }
.lib-tree {
  flex: 0 0 220px; overflow: auto; border-right: 1px solid var(--line);
  padding-right: 8px;
}
.lib-tree-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 13px;
  white-space: nowrap; overflow: hidden;
}
.lib-tree-item:hover { background: var(--bg-raise); }
.lib-tree-item .tree-name { overflow: hidden; text-overflow: ellipsis; }
.tree-icon { color: var(--text-dim); flex: none; font-size: 10px; }
.lib-tree-empty { color: var(--text-dim); font-size: 12px; padding: 8px; }
.lib-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-left: 12px; }
.lib-crumbs { font-size: 13px; margin-bottom: 8px; }
.lib-crumbs a { color: var(--lime-dim); text-decoration: none; }
.lib-crumbs a:hover { color: var(--lime-ink); }
.crumb-sep { color: var(--text-dim); }
.lib-filter {
  margin-bottom: 10px; padding: 6px 10px; max-width: 320px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  color: var(--text); font-size: 13px;
}
.lib-filter:focus { border-color: var(--lime-dim); }
#lib-list { flex: 1; overflow: auto; }
.lib-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.lib-dir { cursor: pointer; }
.lib-dir:hover { background: var(--bg-raise); }
.lib-icon { width: 14px; color: var(--text-dim); flex: none; }
.lib-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-size { color: var(--text-dim); font-size: 12px; flex: none; }
/* the per-row art modifier — a checkbox, so it reads as "on by default"
   rather than as a second thing that downloads */
.lib-art {
  flex: none; display: flex; align-items: center; gap: 4px; cursor: pointer;
  color: var(--text-dim); font-size: 11px; user-select: none;
}
.lib-art-box { margin: 0; accent-color: var(--lime-dim); cursor: pointer; }
.lib-art:hover .lib-art-label { color: var(--text); }

/* ── fleet tab ──────────────────────────────────────────── */
.fleet-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.fleet-summary { font-size: 14px; color: var(--lime-ink); font-weight: 600; }
.fleet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.fleet-note { font-size: 12px; margin-top: 8px; }
.fleet-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  background: var(--bg-panel);
}
.fc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fc-state { font-size: 12px; font-weight: 600; }
.fc-state.ok { color: var(--lime-ink); }
.fc-state.bad { color: var(--err); }
.fc-row { font-size: 12px; color: var(--text-dim); margin-bottom: 3px; }
.fc-dim { opacity: .7; }
.auth-ok { color: var(--lime-ink); }
.auth-bad { color: var(--err); }
.fc-actions { display: flex; gap: 6px; margin-top: 8px; }
.fc-auth-out { font-size: 12px; margin-top: 6px; color: var(--text-dim); min-height: 16px; }
.fc-auth-out a { color: var(--lime-dim); }
.fleet-sec-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin: 18px 0 8px; }
.fleet-traffic { display: flex; flex-direction: column; gap: 6px; }
.tr-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.tr-name { flex: 0 0 70px; font-size: 12px; }
.tr-bar { flex: 1; display: flex; height: 12px; border-radius: 3px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.tr-seg { height: 100%; }
.tr-done { background: rgba(164, 210, 51, 0.4); }
.tr-fail { background: rgba(224, 85, 85, 0.5); }
.tr-queue { background: rgba(125, 138, 120, 0.35); }
.tr-counts { flex: 0 0 220px; font-size: 11px; color: var(--text-dim); }

/* ── player bar (library playback — the LimeWire bottom strip) ── */
#player {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px; font-size: 12px;
  background: var(--bg-panel); color: var(--text);
  border-top: 1px solid var(--line);
}
#player[hidden] { display: none; }
.pl-title { flex: 0 1 280px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-seek { flex: 1 1 auto; min-width: 80px; accent-color: var(--lime); }
.pl-time { flex: none; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.pl-vol { flex: 0 0 90px; accent-color: var(--lime); }
html[data-skin="classic"] #player { box-shadow: inset 0 1px 0 #ffffff; }
html[data-skin="classic"] .pl-seek, html[data-skin="classic"] .pl-vol { accent-color: var(--lime-ink); }

/* ── status bar ─────────────────────────────────────────── */
#status-bar {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 5px 16px; font-size: 12px; color: var(--text-dim);
  border-top: 1px solid var(--line); background: var(--bg-panel);
}
#sb-left.ok { color: var(--lime-ink); }
#sb-left.bad { color: var(--err); }

#sb-left, #sb-center { white-space: nowrap; }
#sb-center { color: var(--text-dim); }
#sb-right {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; text-align: right;
}

/* ── connection banner (aggregator unreachable — retry) ─── */
#conn-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px; font-size: 12px;
  color: var(--err); background: rgba(224, 85, 85, 0.08);
  border-bottom: 1px solid var(--err);
}
#conn-banner[hidden] { display: none; }
#conn-banner .btn { margin-left: auto; }

/* ── shared bits ────────────────────────────────────────── */
.btn {
  appearance: none; border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg-raise); color: var(--text);
  padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.btn:hover { border-color: var(--lime-dim); }
.btn-primary { background: var(--lime); border-color: var(--lime); color: #14200a; font-weight: 700; }
.btn-primary:hover { background: #b8e34e; }

.chip {
  display: inline-block; padding: 1px 8px; border-radius: 3px;
  font-size: 11px; font-weight: 600; color: #0d120d;
}
.chip.qobuz   { background: var(--chip-qobuz); }
.chip.tidal   { background: var(--chip-tidal); color: #fff; }
.chip.deezer  { background: var(--chip-deezer); color: #fff; }
.chip.slskd   { background: var(--lime); color: var(--bg); }
.chip.unknown { background: var(--bg-raise); color: var(--text-dim); border: 1px solid var(--line); }

.empty {
  color: var(--text-dim); text-align: center; padding: 60px 0; font-size: 15px;
}

/* Keyboard focus ring (mouse clicks don't trigger :focus-visible).
   The two inputs above restyle their border on :focus; this ring is the
   shared affordance for everything else — tabs, buttons, selects, rows. */
:focus-visible { outline: 2px solid var(--lime-ink); outline-offset: 1px; }
#search-input:focus-visible, .lib-filter:focus-visible { outline-offset: -1px; }
.error-banner {
  margin: 0 0 12px; padding: 8px 14px;
  border: 1px solid var(--err); border-radius: 4px;
  color: var(--err); background: rgba(224, 85, 85, .08); font-size: 13px;
}

/* Soulseek is a live P2P query and can take 20-40s, so it gets its own
   status line: without it, "still searching" and "nothing there" look
   identical (and a slow lane just reads as an empty result). */
.slsk-status {
  display: inline-block; margin: 0 0 12px; padding: 4px 11px;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--bg-raise); color: var(--text-dim);
  font-size: 12px; letter-spacing: .01em;
}
.slsk-status.slsk-pending { border-color: var(--lime-dim); color: var(--lime-ink); }
.slsk-status.slsk-pending::before {
  content: ''; display: inline-block; width: 7px; height: 7px;
  margin-right: 7px; border-radius: 50%; background: var(--lime);
  vertical-align: middle; animation: slsk-pulse 1s ease-in-out infinite;
}
.slsk-status.slsk-ok { border-color: var(--lime-dim); color: var(--lime-ink); }
.slsk-status.slsk-empty { border-color: var(--line); color: var(--text-dim); font-style: italic; }
.slsk-status.slsk-error {
  border-color: var(--err); color: var(--err); background: rgba(224, 85, 85, .08);
}
@keyframes slsk-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

/* ── classic skin (retro grey "Swing" paint — spec §palette) ──────────────
   A switchable skin: same layout, nostalgic paint. Driven by
   [data-skin="classic"] on <html> (dark is the default; app.js persists the
   choice, an inline head script restores it before first paint). Sizes are
   deliberately NOT set here for phones — the mobile layer below keeps its
   tap-target overrides and wins for them; only the >=769px block tightens
   desktop density. Every value was contrast-measured (shrike-retro-pass doc,
   R2). */
html[data-skin="classic"] {
  --bg: #c9c6bf;
  --bg-panel: #d6d3ce;
  --bg-raise: #e4e1da;
  --line: #8f8c85;
  --text: #14160f;
  --text-dim: #4a4d47;
  --lime-ink: #3d5a06;
  --err: #a01b1b;
  --warn: #6f4a00;
  /* Stage hues darken so borders/dots hold >=3:1 on grey (measured). */
  --stage-enqueued: #6b6f66;
  --stage-downloading: #0f7a72;
  --stage-converting: #6a3fd0;
  --stage-importing: #8a5a00;
  --stage-landed: #3d5a06;
  --stage-downloading-tint: rgba(15, 122, 114, 0.55);
  --stage-converting-tint: rgba(106, 63, 208, 0.5);
  --stage-importing-tint: rgba(138, 90, 0, 0.55);
}
/* Chrome: square corners, hard bevels, sunken fields. */
html[data-skin="classic"] .btn,
html[data-skin="classic"] .type-tab,
html[data-skin="classic"] .tab {
  border-radius: 0;
  border: 1px solid #6e6b66;
  box-shadow: inset 1px 1px 0 #ffffff, inset -1px -1px 0 #9a968e;
  background: var(--bg-panel);
}
html[data-skin="classic"] .btn:active { box-shadow: inset 1px 1px 0 #9a968e, inset -1px -1px 0 #ffffff; }
html[data-skin="classic"] .btn-primary { border-color: #5e6b34; }
html[data-skin="classic"] .tab { border-bottom: none; }
html[data-skin="classic"] .tab.active { background: var(--bg-raise); box-shadow: inset 1px 1px 0 #ffffff; }
html[data-skin="classic"] #search-input,
html[data-skin="classic"] #search-sort,
html[data-skin="classic"] #search-quality,
html[data-skin="classic"] #lib-filter,
html[data-skin="classic"] .lane-select {
  background: #ffffff; border: 1px solid #6e6b66; border-radius: 0;
  box-shadow: inset 1px 1px 0 #b8b4ac;
}
html[data-skin="classic"] .result-row,
html[data-skin="classic"] .tf-row { background: var(--bg-raise); }
html[data-skin="classic"] .result-row:hover { border-color: var(--lime-ink); }
html[data-skin="classic"] .chip.slskd { color: #14200a; }
html[data-skin="classic"] .status-dot.ok,
html[data-skin="classic"] .tf-row[data-stage="landed"]::before,
html[data-skin="classic"] .slsk-status.slsk-pending::before { background: var(--stage-landed); }
html[data-skin="classic"] .chip,
html[data-skin="classic"] .qual-badge,
html[data-skin="classic"] .result-kind,
html[data-skin="classic"] .slsk-status,
html[data-skin="classic"] .lib-tree-item,
html[data-skin="classic"] .chunked-bar,
html[data-skin="classic"] .chunked-bar .fill,
html[data-skin="classic"] .fleet-card,
html[data-skin="classic"] .p2p-album-group,
html[data-skin="classic"] .confirm-box,
html[data-skin="classic"] .cover,
html[data-skin="classic"] .result-row,
html[data-skin="classic"] .tf-row,
html[data-skin="classic"] .tf-truncated,
html[data-skin="classic"] .tr-bar,
html[data-skin="classic"] .dl-chip,
html[data-skin="classic"] .p2p-track-group,
html[data-skin="classic"] .p2p-peer,
html[data-skin="classic"] .p2p-partial,
html[data-skin="classic"] .p2p-fit-bad,
html[data-skin="classic"] .p2p-fit-ok,
html[data-skin="classic"] .p2p-blocked,
html[data-skin="classic"] .p2p-dur,
html[data-skin="classic"] .error-banner,
html[data-skin="classic"] #toast { border-radius: 0; }
html[data-skin="classic"] #status-bar { box-shadow: inset 0 1px 0 #ffffff; }
/* Classic skin: JTable-ish lists — zebra striping, hairline grid, square rows.
   Zebra #cecbc4 measured: text 11.3:1, dim 5.3:1, lime ink 4.9:1, err 4.9:1. */
html[data-skin="classic"] .result-row,
html[data-skin="classic"] .lib-row {
  border-radius: 0; border-left: 0; border-right: 0;
  border-bottom: 1px solid #b9b5ad; margin-bottom: 0;
}
html[data-skin="classic"] .tf-row {
  border-radius: 0; border-right: 0; border-bottom: 1px solid #b9b5ad; margin-bottom: 0;
}
html[data-skin="classic"] .result-row:nth-child(even),
html[data-skin="classic"] .tf-row:nth-child(even),
html[data-skin="classic"] .lib-row:nth-child(even) { background: #cecbc4; }
html[data-skin="classic"] .result-row:hover,
html[data-skin="classic"] .lib-row:hover { background: #ddd9d2; }
/* Numeric metas line up in both skins (tabular figures, Swing-style). */
.result-sub, .tf-sub, .lib-size, .tr-counts, #status-bar { font-variant-numeric: tabular-nums; }
/* Desktop density — the phone block below keeps its tap-target sizes. */
@media (min-width: 769px) {
  html[data-skin="classic"] .panel { padding: 12px; }
  html[data-skin="classic"] .result-row,
  html[data-skin="classic"] .tf-row { padding: 5px 8px; gap: 8px; margin-bottom: 3px; }
  html[data-skin="classic"] .cover { width: 36px; height: 36px; }
  html[data-skin="classic"] .lib-tree-item { padding: 3px 8px; }
  html[data-skin="classic"] .fleet-grid { gap: 8px; }
}

/* ── mobile layer ────────────────────────────────────────── */
/* NOTE: This block must come AFTER all base rules in source order.
   Equal-specificity selectors resolve by last-declared, so the mobile
   overrides below win against the base rules only when they follow them. */

/* kill tap flash / text-selection on interactive chrome */
* { -webkit-tap-highlight-color: transparent; }

/* phones: stack the header, search drops below wordmark */
@media (max-width: 768px) {
  .p2p-filters { gap: 10px; }
  .p2p-f-label, .p2p-check { min-height: 44px; }  /* touch target floor (mobile review) */
  .p2p-f-label select { min-height: 44px; padding: 6px 10px; }
  .p2p-check input { width: 24px; height: 24px; }
  .p2p-inspect-check { width: 24px; height: 24px; }
  .p2p-clear { min-height: 44px; }
  #app-header { flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
  /* conn-status stays observable on phones: dot only, label hidden */
  #status-label { display: none; }
  #search-form { flex: 1 1 100%; order: 3; padding: 2px 0 4px; }
  #search-input { padding: 10px 12px; }

  /* Controls row: wrap instead of overflowing. Measured at 390px the row is
     559px wide against the 370px column, so the sort/quality selects sat
     off-screen behind a horizontal drag (the panel is the scroller, not the
     page — `overflow: auto` on .panel). */
  .search-controls, .tf-head { flex-wrap: wrap; gap: 8px; }
  .sort-label, .quality-label { margin-left: 0; }
  .slsk-toggle { margin-left: 0; }
  .type-tabs { flex-wrap: wrap; }

  /* The anti-zoom rule above (`body, input, select, button { 16px }`) loses to
     every id/class rule it was written for — measured #search-input 14px,
     #search-sort/.lane-select 12px — so iOS still zoomed on focus of the search
     box. Name the typable controls explicitly. Buttons are deliberately NOT in
     this list: iOS zooms on text-entry focus only, and 16px buttons widened the
     result rows past a 320px screen by a further 13px. */
  #search-input, #lib-filter, #search-sort, #search-quality,
  .lane-select, .lib-format, textarea { font-size: 16px; }

  /* tabs scroll horizontally instead of overflowing */
  #tab-strip {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 6px 10px 0; scrollbar-width: none;
  }
  #tab-strip::-webkit-scrollbar { display: none; }
  .tab { padding: 10px 16px 11px; flex: 0 0 auto; min-height: 40px; }

  .panel { padding: 12px 10px; }

  /* search results: cover/badges stack, title wraps. flex-wrap matters: the
     row is the panel's widest content, and `.result-badges` is width:100%,
     which in a nowrap row demanded 340px inside a 300px row at 320px —
     panning the whole list sideways (`.panel` is the horizontal scroller). */
  .result-row { align-items: flex-start; gap: 8px; padding: 10px 8px; flex-wrap: wrap; }
  .cover { width: 36px; height: 36px; }
  .result-title { white-space: normal; font-size: 14px; }
  .result-sub { white-space: normal; }
  .result-badges { margin-left: 0; width: 100%; }

  /* P2P group header meta is long (artist · year · peer · N files · size ·
     speed) and measured 432px wide at 390px — it panned the panel too. The
     title is a filename-style string, so allow it to break rather than
     stretch the line (it measured 335px at 320px). */
  .p2p-album-group summary { flex-wrap: wrap; }
  .p2p-album-title { min-width: 0; overflow-wrap: anywhere; }

  /* transfers: bar collapses to full width under the title */
  .tf-fleet-actions { flex: 1 1 100%; margin-left: 0; justify-content: flex-end; }
  .tf-row { flex-wrap: wrap; align-items: flex-start; }
  .tf-bar-cell { flex: 1 1 100%; order: 5; }
  .tf-actions { margin-left: 0; margin-top: 6px; }

  /* library: tree collapses to a top drawer */
  .lib-layout { flex-direction: column !important; height: auto; }
  .lib-tree {
    flex: 1 1 auto; border-right: none; border-bottom: 1px solid var(--line);
    padding: 4px 8px 8px; max-height: 200px; overflow-y: auto;
  }
  .lib-main { padding-left: 0; }

  /* fleet: single column */
  .fleet-grid { grid-template-columns: 1fr; }
  .fleet-actions { flex-wrap: wrap; }
  .tr-counts { flex: 1 1 100%; margin-top: 4px; }

  /* shared: roomier tap targets. Measured before this pass at 390px: type tabs
     36px, sort/quality selects 27/21px, lane selects 27px, .btn-xs 32px,
     library tree rows 27px, #lib-filter 32px, export checkboxes 13px. Targets:
     44px for type tabs, 40px for controls and row actions, 36px for the dense
     library tree (WCAG 2.2 AA floors at 24px; iOS HIG asks 44). */
  .btn { padding: 10px 14px; min-height: 40px; }
  .btn-xs { padding: 9px 12px; min-height: 40px; font-size: 12px; }
  .type-tab { min-height: 44px; padding: 10px 14px; }
  #search-sort, #search-quality, .lane-select, #lib-filter { min-height: 40px; }
  .slsk-toggle { min-height: 40px; }
  .slsk-toggle input { width: 24px; height: 24px; }
  .lib-tree-item { min-height: 36px; padding: 6px 8px; }
  /* 24px, not 20: WCAG 2.2 AA target size (2.5.8) wants 24x24 in BOTH
     dimensions, and enlarging a native control to 20px forfeits the
     user-agent-control exception it would otherwise enjoy at native size. */
  .lib-art-box { width: 24px; height: 24px; }
  /* Breadcrumbs are inline links in a path sentence — left as-is under the
     WCAG target-size exception for inline text. */

  /* status bar: center hidden, left shorter */
  #sb-center { display: none; }

  /* Anti-zoom: >=16px stops iOS zooming on focus (phone-only). */
  body, input, select, button { font-size: 16px; }

  /* player: title on its own line; iOS owns hardware volume */
  #player { flex-wrap: wrap; row-gap: 4px; padding: 6px 10px; }
  .pl-title { flex: 1 1 100%; }
  .pl-vol { display: none; }
}

/* tablets / small laptops: two-column fleet, wider panels */
@media (min-width: 769px) and (max-width: 1100px) {
  .fleet-grid { grid-template-columns: repeat(2, 1fr); }
  .result-title { font-size: 15px; }
}

/* very narrow (<400px): even tighter */
@media (max-width: 400px) {
  #search-form { flex-direction: column; }
  .btn-primary { width: 100%; }
}

/* Motion sensitivity: the two infinite pulses (transfer bar, Soulseek dot)
   and the splash fade are decoration — drop them, keep every state legible. */
@media (prefers-reduced-motion: reduce) {
  .chunked-bar.pulse .fill { animation: none; opacity: .75; }
  .slsk-status.slsk-pending::before { animation: none; }
  #splash { transition: none; }
  .chunked-bar .fill { transition: none; }
  .p2p-album-group summary::before { transition: none; }
}

/* ── confirm dialog (in-house replacement for native confirm) ── */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.confirm-box {
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 6px;
  padding: 16px 18px; width: 100%; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.confirm-msg { margin: 0 0 14px; font-size: 14px; color: var(--text); }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* §7A: Soulseek album lane staircase — ALBUMS -> COPIES -> FILES with a filter row.
   The lane is a labelled source, so the header carries the copy counts the old
   summary line carried, and the filter row states what is being filtered out. */
.p2p-staircase {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.p2p-stair-albums { color: var(--text); }
.p2p-stair-sep { opacity: 0.6; }
.p2p-stair-copies { color: var(--lime); }
.p2p-stair-meta { color: var(--text-dim); }
.p2p-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 0.5rem;
}
.p2p-filter-summary {
  color: var(--text-dim);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.result-section { display: block; }
.result-section-head {
  color: var(--text-dim);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0.25rem 0;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
}
