:root {
  --bg: #0f1012;
  --bg-2: #141518;
  --surface: #191a1e;
  --surface-2: #1f2125;
  --surface-3: #26282d;
  --line: #2a2c32;
  --line-2: #34373e;
  --text: #ecebe8;
  --text-2: #b9b8b4;
  --muted: #8c8c92;
  --accent: #ff7a3d;
  --accent-2: #ff9a5c;
  --accent-ink: #1a0d06;
  --accent-soft: rgba(255, 122, 61, 0.14);
  --ok: #3ecf8e;
  --ok-soft: rgba(62, 207, 142, 0.14);
  --warn: #f5b14c;
  --warn-soft: rgba(245, 177, 76, 0.14);
  --bad: #ef5b5b;
  --bad-soft: rgba(239, 91, 91, 0.14);
  --info: #6aa8ff;
  --info-soft: rgba(106, 168, 255, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sidebar: 232px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- controls ---------------------------------------------------------- */

input, select, textarea, button { font: inherit; color: inherit; }
input[type="search"], input[type="password"], input[type="number"], input:not([type]), select, textarea {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  min-height: 38px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; }
select { width: auto; cursor: pointer; padding-right: 28px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: #66666c; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-2); }
.btn-block { width: 100%; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #f47272; }
.btn-danger-text:hover:not(:disabled) { color: var(--bad); border-color: rgba(239, 91, 91, 0.45); background: var(--bad-soft); }
.ok-btn { color: var(--ok); }

/* Keyboard focus: visible ring on everything clickable (mouse clicks don't trigger it) */
:is(a, button, .chip, .album, [role="button"], [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:focus-visible, .icon-btn:focus-visible { outline-offset: 1px; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px;
  background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.check { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); cursor: pointer; white-space: nowrap; user-select: none; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; color: var(--text-2); user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 36px; height: 20px; border-radius: 20px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; flex: none; transition: background 0.15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform 0.15s, background 0.15s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); background: var(--accent-ink); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-soft); }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 600; }

/* ---- login --------------------------------------------------------------- */

.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(600px 400px at 50% 30%, rgba(255, 122, 61, 0.09), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 30px 26px 26px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin: 12px 0 4px; font-size: 26px; }
.login-card .muted { margin: 0 0 22px; }
.login-card .field { text-align: left; }
.login-logo { filter: drop-shadow(0 6px 18px rgba(255, 122, 61, 0.35)); }
.form-error { color: var(--bad); min-height: 20px; margin: 0 0 10px; font-size: 13px; text-align: left; }

/* ---- shell ---------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100%; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  background: var(--bg-2); border-right: 1px solid var(--line); padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--text); font-weight: 750; font-size: 19px; letter-spacing: -0.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; position: relative; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent-2); }
.nav a.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; display: grid; place-items: center; font-weight: 750; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px; border-top: 1px solid var(--line); }
.conn-pill { display: flex; align-items: center; gap: 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; font-weight: 600; text-align: left; color: var(--text-2); min-width: 0; }
.conn-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.conn-pill[data-state="online"] .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.conn-pill[data-state="connecting"] .dot, .conn-pill[data-state="starting"] .dot { background: var(--warn); animation: pulse 1.2s infinite; }
.conn-pill[data-state="error"] .dot, .conn-pill[data-state="setup"] .dot { background: var(--bad); }
.rates { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rates b { color: var(--text-2); font-weight: 600; }
.disk { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.disk.low { color: var(--bad); font-weight: 600; }
.demo-flag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--info); background: var(--info-soft); border-radius: 6px; padding: 3px 8px; align-self: flex-start; }

.main { padding: 26px 32px 60px; min-width: 0; }
.view { max-width: 1120px; margin: 0 auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.view-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view-head .actions input[type="search"] { width: 220px; }

@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- banner --------------------------------------------------------------- */

.banner { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap;
  background: var(--warn-soft); border: 1px solid rgba(245, 177, 76, 0.35); color: #f7d49a; border-radius: var(--radius); padding: 11px 14px; margin-bottom: 16px; }
.banner.bad { background: var(--bad-soft); border-color: rgba(239, 91, 91, 0.35); color: #f5b0b0; }

/* ---- search ----------------------------------------------------------------- */

.searchbar { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 7px 7px 7px 16px; transition: border-color 0.15s, box-shadow 0.15s; }
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.searchbar svg { color: var(--muted); }
.searchbar input { border: 0; background: transparent; box-shadow: none !important; font-size: 16px; padding: 6px 0; min-height: 40px; }
.searchbar .btn { min-height: 40px; padding: 0 20px; border-radius: 10px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; max-width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 13px; cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 13px; }
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip.on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.chip .q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .n { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip .x { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.chip .x:hover { background: var(--surface-3); color: var(--text); }
.chip .x svg { width: 13px; height: 13px; }

.empty { text-align: center; padding: 70px 20px; max-width: 520px; margin: 0 auto; }
.empty img { opacity: 0.9; margin-bottom: 14px; }
.empty p { margin: 6px 0; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0 10px; }
.filters input[type="search"] { flex: 1 1 200px; width: auto; }
.filter-opts { display: contents; }
.results-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12.5px; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--accent-2); font-weight: 600; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }

.cards { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color 0.15s; min-width: 0; }
.card:hover { border-color: var(--line-2); }
.card-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 14px 13px 16px; }
.card-title {
  font-weight: 650; font-size: 15px; line-height: 1.3; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.card-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; direction: ltr; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 8px; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.meta .user { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--text); }
.meta .user svg { width: 13px; height: 13px; color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 5px; border-radius: 6px; padding: 2px 7px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em; background: var(--surface-3); color: var(--text-2); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.fmt { background: var(--accent-soft); color: var(--accent-2); }
.card-actions { display: flex; gap: 6px; align-items: center; }
.chev { transition: transform 0.15s; }
.card.open .chev { transform: rotate(180deg); }

.tracks { border-top: 1px solid var(--line); padding: 4px 6px 8px; }
.track { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto auto 30px; gap: 12px; align-items: center; padding: 6px 8px; border-radius: 7px; font-size: 13px; font-variant-numeric: tabular-nums; }
.track:hover { background: var(--surface-2); }
.track .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track.dim .name { color: var(--muted); }
.track .c { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.tracks-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 8px 2px; flex-wrap: wrap; }

/* ---- downloads --------------------------------------------------------------- */

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 14px; flex-wrap: wrap; }
.seg button { background: transparent; border: 0; border-radius: 7px; padding: 6px 13px; color: var(--text-2); font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.seg button .n { color: var(--muted); font-weight: 500; margin-left: 4px; font-variant-numeric: tabular-nums; }

.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 6px; background: var(--accent); transition: width 0.6s ease; }
.progress.ok > i { background: var(--ok); }
.progress.bad > i { background: var(--bad); }
.progress.idle > i { background: var(--muted); }
.card .progress { margin-top: 10px; }

.dl-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 92px auto; gap: 12px; align-items: center; padding: 7px 8px; border-radius: 7px; font-size: 13px; font-variant-numeric: tabular-nums; }
.dl-row:hover { background: var(--surface-2); }
.dl-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-row .sub { font-size: 11.5px; color: var(--muted); }
.dl-row .progress { height: 4px; margin-top: 5px; }
.dl-row .c { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ---- settings ---------------------------------------------------------------- */

.settings { max-width: 760px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 6px; margin: 0 0 14px; min-width: 0; }
.panel legend { float: left; width: 100%; padding: 0; margin-bottom: 10px; font-weight: 700; font-size: 15px; }
.panel legend ~ * { clear: both; }
.panel > p { margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
body.has-player .savebar { bottom: 84px; }
body.has-player .log { max-height: calc(100vh - 270px); }
.savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 12px 0; margin-bottom: 18px; background: linear-gradient(transparent, var(--bg) 35%); }

/* ---- activity ----------------------------------------------------------------- */

.log { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 0; font-family: var(--mono); font-size: 12.5px; max-height: calc(100vh - 170px); overflow: auto; }
.log div { padding: 2px 14px; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.log div:hover { background: var(--surface); }
.log time { color: #6d6d74; margin-right: 10px; }
.log input[type="search"] { width: 220px; }
#log-filter { width: 220px; }

/* ---- toasts -------------------------------------------------------------------- */

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; background: var(--surface-3); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 360px; font-size: 13px; animation: toast-in 0.2s ease; }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.spinner { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }

/* ---- responsive ---------------------------------------------------------------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 20; top: auto; bottom: 0; left: 0; right: 0; height: auto;
    flex-direction: row; align-items: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); background: rgba(20, 21, 24, 0.96); backdrop-filter: blur(10px);
  }
  .brand, .sidebar-foot .rates, .demo-flag, .disk { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; padding: 6px 10px; font-size: 11px; }
  .nav a.on::before { display: none; }
  .nav .badge { position: absolute; top: 0; right: 4px; margin: 0; min-width: 17px; height: 17px; font-size: 10px; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; }
  .conn-pill { padding: 8px; }
  .conn-pill span { display: none; }
  .main { padding: 16px 16px 96px; }
  .grid2 { grid-template-columns: 1fr; }
  .card-head { grid-template-columns: minmax(0, 1fr); }
  .card-actions { justify-content: flex-start; }
  .track { grid-template-columns: 22px minmax(0, 1fr) auto 28px; gap: 8px; }
  .track .c.hide-sm { display: none; }
  .dl-row { grid-template-columns: minmax(0, 1fr) auto; }
  .dl-row .c { display: none; }
  .toasts { left: 16px; right: 16px; bottom: 84px; }
  .toast { max-width: none; }
  .log { max-height: calc(100vh - 230px); }
}

/* ---- library ------------------------------------------------------------------- */

svg .fill { fill: currentColor; stroke: none; }

.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 22px 18px; }
.album { min-width: 0; cursor: pointer; border-radius: 12px; outline: none; }
.album:focus-visible .art { box-shadow: 0 0 0 3px var(--accent); }
.art { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35); }
.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.art .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(22px, 4vw, 40px); font-weight: 800; letter-spacing: -0.02em; color: rgba(255, 255, 255, 0.88);
  background: linear-gradient(135deg, hsl(var(--h, 20) 55% 40%), hsl(calc(var(--h, 20) + 50) 55% 18%));
}
.play-fab {
  position: absolute; right: 10px; bottom: 10px; width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45); opacity: 0; transform: translateY(6px); transition: opacity 0.15s, transform 0.15s;
}
.play-fab svg { fill: currentColor; stroke: none; width: 20px; height: 20px; margin-left: 2px; }
.album:hover .play-fab, .album:focus-within .play-fab { opacity: 1; transform: none; }
.play-fab:hover { background: var(--accent-2); }
@media (hover: none) { .play-fab { opacity: 1; transform: none; width: 40px; height: 40px; } }
.album .t {
  margin-top: 10px; font-weight: 650; line-height: 1.3; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.art-badge {
  position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 6px; border-radius: 999px; background: rgba(10, 10, 12, 0.78); color: var(--text);
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; backdrop-filter: blur(4px);
}
.art-badge .spinner { width: 11px; height: 11px; border-width: 2px; }
.notice {
  display: flex; align-items: center; gap: 10px; margin: -8px 0 16px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--info-soft); color: #b9d4ff; font-size: 13px;
}
.album .s { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.album.playing .t { color: var(--accent-2); }

.album-hero { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 26px; align-items: end; margin: 14px 0 22px; }
.album-hero .art { border-radius: 12px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11.5px; font-weight: 700; color: var(--muted); margin: 0 0 6px; }
.album-hero h1 { font-size: clamp(24px, 3.4vw, 38px); line-height: 1.1; margin: 0 0 8px; word-break: break-word; }
.album-hero .muted { margin: 0 0 16px; }

.tracklist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; }
.trow { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 32px; gap: 12px; align-items: center; padding: 8px; border-radius: 8px; cursor: pointer; font-variant-numeric: tabular-nums; }
.trow:hover { background: var(--surface-2); }
.trow .num { color: var(--muted); text-align: center; font-size: 13px; }
.trow .tt { min-width: 0; display: flex; flex-direction: column; }
.trow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .c { color: var(--muted); font-size: 12.5px; }
.trow.on .name, .trow.on .num { color: var(--accent-2); }
.trow.bad { cursor: default; opacity: 0.5; }
.trow .hover-play { display: none; }
.trow:not(.bad):hover .num .n { display: none; }
.trow:not(.bad):hover .num .hover-play { display: inline; }
.trow .num svg { width: 14px; height: 14px; fill: currentColor; stroke: none; vertical-align: -2px; }
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.eq i { width: 3px; background: var(--accent); border-radius: 1px; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }
.paused .eq i { animation-play-state: paused; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

/* ---- player ---------------------------------------------------------------------- */

body.has-player .main { padding-bottom: 130px; }
body.has-player .toasts { bottom: 100px; }

.player {
  position: fixed; z-index: 15; left: var(--sidebar); right: 0; bottom: 0; height: 84px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr); align-items: center; gap: 18px;
  padding: 0 20px; background: rgba(18, 19, 22, 0.97); border-top: 1px solid var(--line); backdrop-filter: blur(12px);
}
.pl-now { display: flex; align-items: center; gap: 12px; min-width: 0; background: none; border: 0; padding: 6px; margin-left: -6px; border-radius: 10px; text-align: left; cursor: pointer; color: inherit; }
.pl-now:hover { background: var(--surface-2); }
.pl-art { position: relative; width: 50px; height: 50px; flex: none; border-radius: 7px; overflow: hidden; background: linear-gradient(135deg, var(--surface-3), var(--surface-2)); }
.pl-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-art .ph {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 800; color: rgba(255, 255, 255, 0.88);
  background: linear-gradient(135deg, hsl(var(--h, 20) 55% 40%), hsl(calc(var(--h, 20) + 50) 55% 18%));
}
.pl-art img[hidden] { display: none; }
.pl-text { display: flex; flex-direction: column; min-width: 0; }
.pl-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pl-center { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.pl-buttons { display: flex; align-items: center; gap: 12px; }
.pl-buttons .icon-btn { width: 34px; height: 34px; color: var(--text-2); }
.pl-buttons .icon-btn svg { width: 18px; height: 18px; }
.pl-play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); display: grid; place-items: center; cursor: pointer; transition: transform 0.1s; }
.pl-play:hover { transform: scale(1.06); }
.pl-play svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.pl-play .i-pause, .player.playing .pl-play .i-play { display: none; }
.player.playing .pl-play .i-pause { display: block; }
.pl-play .i-play { margin-left: 2px; }
.pl-opt { position: relative; }
.pl-opt[data-mode="all"], .pl-opt[data-mode="one"] { color: var(--accent) !important; }
.pl-opt .one { display: none; position: absolute; right: 3px; bottom: 2px; font-size: 9px; line-height: 1; }
.pl-opt[data-mode="one"] .one { display: block; }

.pl-timeline { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 600px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pl-timeline span { min-width: 36px; }
.pl-timeline span:first-child { text-align: right; }
.pl-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.player.muted #pl-mute .wave { opacity: 0.2; }

.player input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 4px; margin: 8px 0; padding: 0; border: 0; border-radius: 4px; cursor: pointer;
  background: linear-gradient(to right, var(--text-2) var(--pct, 0%), var(--surface-3) var(--pct, 0%));
}
.player input[type="range"]:hover, .player input[type="range"]:focus-visible { background: linear-gradient(to right, var(--accent) var(--pct, 0%), var(--surface-3) var(--pct, 0%)); outline: none; }
.player input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--text); opacity: 0; transition: opacity 0.15s; }
.player input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: var(--text); opacity: 0; }
.player input[type="range"]:hover::-webkit-slider-thumb, .player input[type="range"]:focus-visible::-webkit-slider-thumb { opacity: 1; }
.player input[type="range"]:hover::-moz-range-thumb { opacity: 1; }
#pl-volume { flex: 0 0 100px; }

.queue {
  position: fixed; z-index: 16; right: 16px; bottom: 96px; width: 390px; max-height: min(62vh, 580px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow);
}
.queue header { display: flex; align-items: center; gap: 8px; padding: 12px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.queue h2 { margin: 0; font-size: 15px; flex: 1; }
.queue ol { list-style: none; margin: 0; padding: 6px; overflow: auto; }
.queue li { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 6px 6px 8px; border-radius: 8px; cursor: pointer; }
.queue li:hover { background: var(--surface-2); }
.queue li.on { background: var(--accent-soft); }
.queue li.on .qt { color: var(--accent-2); }
.queue li.done { opacity: 0.55; }
.queue .qa { position: relative; width: 38px; height: 38px; border-radius: 5px; overflow: hidden; background: linear-gradient(135deg, hsl(var(--h, 20) 55% 40%), hsl(calc(var(--h, 20) + 50) 55% 18%)); }
.queue .qa img { width: 100%; height: 100%; object-fit: cover; display: block; }
.queue .qt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.queue .qs { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.queue li.empty-q { display: block; padding: 26px 16px; text-align: center; color: var(--muted); cursor: default; }
.queue li.empty-q:hover { background: none; }
.queue .qt, .queue .qs { display: block; }

@media (max-width: 860px) {
  .nav a { padding: 6px 4px; font-size: 10.5px; min-width: 0; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 12px; }
  .album-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 16px; }
  .album-hero .art { width: min(240px, 70vw); }
  .album-hero .actions { justify-content: center; }
  .trow { grid-template-columns: 26px minmax(0, 1fr) auto 30px; gap: 8px; }

  body.has-player .main { padding-bottom: 170px; }
  body.has-player .toasts { bottom: 150px; }
  .player {
    left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); height: 62px; padding: 0 10px 0 8px;
    grid-template-columns: minmax(0, 1fr) auto; gap: 6px; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden;
  }
  .pl-now { padding: 4px; margin: 0; }
  .pl-art { width: 44px; height: 44px; }
  .pl-center { flex-direction: row; }
  .pl-timeline { position: absolute; left: 0; right: 0; bottom: 0; max-width: none; gap: 0; }
  .pl-timeline span { display: none; }
  /* A 3px bar to look at, but a 14px strip to tap */
  .player .pl-timeline input[type="range"],
  .player .pl-timeline input[type="range"]:hover,
  .player .pl-timeline input[type="range"]:focus-visible {
    height: 14px; margin: 0; border-radius: 0;
    background-size: 100% 3px; background-repeat: no-repeat; background-position: left bottom;
  }
  #pl-prev, #pl-repeat, .pl-right { display: none; }
  .pl-buttons { gap: 4px; }
  .queue { left: 8px; right: 8px; width: auto; bottom: calc(136px + env(safe-area-inset-bottom)); max-height: 58vh; }
}

/* ---- confirm dialog ------------------------------------------------------------- */

.dialog {
  width: min(440px, calc(100% - 32px)); padding: 22px 22px 18px; border: 1px solid var(--line-2); border-radius: 16px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(2px); }
.dialog h2 { font-size: 18px; margin: 0 0 8px; overflow-wrap: anywhere; }
.dialog p { margin: 0 0 20px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- phone fixes ------------------------------------------------------------------ */

@media (max-width: 860px) {
  /* Filters: search box on its own row, everything else in one swipeable row */
  .filters { flex-direction: column; align-items: stretch; }
  .filters input[type="search"] { flex: none; width: 100%; }
  .filter-opts {
    display: flex; gap: 8px; align-items: center; overflow-x: auto; flex-wrap: nowrap;
    margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none;
  }
  .filter-opts::-webkit-scrollbar { display: none; }
  .filter-opts select { flex: none; }
  .filter-opts .check { padding-right: 4px; }

  /* Downloads: keep each file's status visible, drop the size column */
  .dl-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .dl-row .c-status { display: block; }

  /* Sticky save bar and log sit above the tab bar and player */
  .savebar { bottom: calc(62px + env(safe-area-inset-bottom)); }
  body.has-player .savebar { bottom: calc(132px + env(safe-area-inset-bottom)); }
  body.has-player .log { max-height: calc(100vh - 340px); }

  .view-head .actions { width: 100%; }
  .view-head .actions input[type="search"] { flex: 1 1 100%; width: auto; min-width: 0; }
  .view-head .actions select, .view-head .actions .btn { flex: 1 1 0; }
  .album-hero .actions .btn { flex: 1 1 auto; }
}
