:root {
  --bg: #0c0d10;
  --bg2: #111317;
  --panel: #16181d;
  --panel2: #1d2027;
  --hover: #22262e;
  --line: #262a32;
  --line2: #323743;
  --text: #eceef2;
  --muted: #8a909c;
  --dim: #5d6370;
  --acc: #2ee59d;
  --acc-ink: #03170e;
  --acc-soft: rgba(46, 229, 157, .12);
  --bad: #ff6272;
  --warn: #ffb547;
  --r: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
#app { display: flex; flex-direction: column; height: 100vh; min-width: 260px; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- иконки ---------- */
.ic { width: 16px; height: 16px; display: block; flex: none; }
.ic.f { fill: currentColor; }
.ic.s { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- кнопки ---------- */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); line-height: 1; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, transform .08s;
}
button:hover { background: var(--hover); border-color: var(--line2); }
button:active { transform: scale(.96); }
button:disabled { opacity: .35; cursor: default; transform: none; }
button.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.sm { height: 28px; padding: 0 10px; font-size: 12px; }
button.sm .ic { width: 14px; height: 14px; }
.ib { width: 30px; padding: 0; }
.ib.sm { width: 28px; }
.ib.accent { color: var(--acc); }
.push { margin-left: auto; }

input[type=search], select {
  height: 30px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; min-width: 0; transition: border-color .12s;
}
select { padding-right: 6px; cursor: pointer; }
input[type=search]:hover, select:hover { border-color: var(--line2); }
input:focus, select:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
input::placeholder { color: var(--dim); }

/* ---------- шапка ---------- */
.top { padding: 8px 10px; background: var(--bg2); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 6px; align-items: center; }
.bar-r { display: flex; gap: 4px; margin-left: auto; }
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.seg button { height: 26px; border: 0; border-radius: 7px; background: transparent; padding: 0 10px; color: var(--muted); font-size: 12px; }
.seg button:hover { background: var(--hover); color: var(--text); }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 1px 3px rgba(0,0,0,.4); }
.count { min-width: 18px; height: 16px; padding: 0 5px; border-radius: 99px; background: var(--acc-soft); color: var(--acc); font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.search { position: relative; }
.search-ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--dim); pointer-events: none; }
.search #q { flex: 1; height: 34px; padding-left: 34px; font-size: 14px; }
.search .primary { height: 34px; padding: 0 16px; }
.curq { display: none; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.srcs { display: flex; flex-wrap: wrap; gap: 4px; }
.srcs:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; height: 22px; padding: 0 9px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.chip.ok::before { background: var(--acc); }
.chip.ok { color: var(--text); }
.chip.err::before { background: var(--bad); }
.chip.err { cursor: help; }
.chip.load::before { background: var(--warn); animation: pulse 1s infinite; }
.chip a { color: var(--acc); }
@keyframes pulse { 50% { opacity: .3; } }

/* свёрнутая панель: только строка вкладок и список */
#app.collapsed #searchForm, #app.collapsed #srcs, #app.collapsed .tools,
#app.collapsed #years, #app.collapsed #summary, #app.collapsed #mode { display: none !important; }
#app.collapsed .top { padding: 6px 8px; }
#app.collapsed .curq { display: block; flex: 1; }

/* ---------- панели инструментов ---------- */
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tools #filter, #libFilter { flex: 1; min-width: 80px; }
#libView .tools { flex-wrap: nowrap; }
#libView .tools > * { flex: none; }
#plSel, #libSort { flex: 1 1 auto !important; min-width: 0; max-width: 220px; }
#libFilter { flex: 1 1 60px !important; }
.chk { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; }
.chk input { appearance: none; width: 28px; height: 16px; margin: 0; border-radius: 99px; background: var(--line2); position: relative; cursor: pointer; transition: background .15s; }
.chk input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; }
.chk input:checked { background: var(--acc); }
.chk input:checked::after { transform: translateX(12px); }
.years { display: flex; gap: 4px; overflow-x: auto; padding: 6px 10px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.years:empty { display: none; }
.years button { height: 22px; font-size: 11px; padding: 0 8px; border-radius: 99px; flex: none; color: var(--muted); }
.years button:hover { color: var(--acc); border-color: var(--acc); }
.summary { display: flex; align-items: center; gap: 8px; padding: 6px 12px 0; color: var(--dim); font-size: 11px; }
.summary:empty { display: none; }
.list { flex: 1; overflow-y: auto; padding: 0 8px 12px; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.empty { color: var(--muted); text-align: center; padding: 48px 20px; line-height: 1.6; }
.empty small { color: var(--dim); }
.empty-ic { display: flex; justify-content: center; margin-bottom: 10px; color: var(--line2); }
.empty-ic .ic { width: 44px; height: 44px; }

/* ---------- годы и релизы ---------- */
.year > h2 { position: sticky; top: 0; z-index: 2; display: flex; align-items: baseline; gap: 8px; margin: 0 -8px; padding: 10px 12px 6px;
  font-size: 18px; font-weight: 700; letter-spacing: -.01em; background: linear-gradient(var(--bg) 75%, transparent); }
.year > h2 small { color: var(--dim); font-weight: 400; font-size: 11px; }
.rel { margin-top: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.rel-h { display: flex; gap: 10px; padding: 8px; align-items: center; }
.rel-h img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--panel2); flex: none; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.rel-h .meta { flex: 1; min-width: 0; }
.rel-h b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-h small { display: flex; align-items: center; gap: 3px; margin-top: 3px; color: var(--muted); font-size: 11.5px; overflow: hidden; white-space: nowrap; }
.rel-h small .info { overflow: hidden; text-overflow: ellipsis; }
.rel-h .pl { width: 32px; height: 32px; }

.trs { list-style: none; margin: 0; padding: 0; }
.tr { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-top: 1px solid var(--line); transition: background .1s; }
.tr:hover { background: var(--hover); }
.tr.playing { background: var(--acc-soft); }
.tr.playing .t b { color: var(--acc); }
.tr.dup { opacity: .45; }
.tr .t { flex: 1; min-width: 0; cursor: pointer; }
.tr .t b { font-weight: 500; }
.tr .t em { color: var(--muted); font-style: normal; }
.tr .t small { display: block; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl { width: 28px; height: 28px; padding: 0; border-radius: 50%; flex: none; background: transparent; border-color: var(--line2); }
.pl .ic { width: 12px; height: 12px; margin-left: 1px; }
.pl:hover, .tr:hover .pl { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.tr.playing .pl { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.add { width: 28px; height: 28px; padding: 0; border-radius: 50%; flex: none; background: transparent; border-color: var(--line2); color: var(--muted); }
.add .ic { width: 14px; height: 14px; }
.add:hover { color: var(--acc); border-color: var(--acc); background: var(--acc-soft); }
.add.on { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }
.add.del:hover { color: var(--bad); border-color: var(--bad); background: rgba(255,98,114,.1); }
.noprev { color: var(--dim); font-size: 11px; flex: none; font-variant-numeric: tabular-nums; }
.grip { cursor: grab; color: var(--dim); flex: none; display: flex; }
.grip .ic { width: 14px; height: 14px; }
#libList .trs { margin-top: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
#libList .tr:first-child { border-top: 0; }
.tr.dragging { opacity: .4; }
.tr.drop-before { box-shadow: inset 0 2px 0 var(--acc); }
.tr.drop-after { box-shadow: inset 0 -2px 0 var(--acc); }

/* ---------- уведомление ---------- */
.toast { margin: 0 10px 8px; padding: 6px 6px 6px 12px; background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--r);
  display: flex; gap: 6px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.45); animation: up .18s ease-out; }
.toast span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes up { from { transform: translateY(6px); opacity: 0; } }

/* ---------- плеер ---------- */
.player { background: var(--bg2); border-top: 1px solid var(--line); }
.progress { height: 14px; margin: -7px 0 -3px; position: relative; z-index: 3; }
.progress input { width: 100%; }
.pinner { display: flex; align-items: center; gap: 10px; padding: 6px 10px 8px; }
.player img { width: 42px; height: 42px; border-radius: 6px; object-fit: cover; background: var(--panel2); flex: none; }
.player img:not([src]), .player img[src=""] { display: none; }
.pmain { flex: 1; min-width: 0; }
.ptitle { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psub { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptime { color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; flex: none; }
.pctl { display: flex; align-items: center; gap: 4px; flex: none; }
.pctl .ib { background: transparent; border-color: transparent; color: var(--muted); }
.pctl .ib:hover { color: var(--text); background: var(--hover); }
.pctl .big { width: 38px; height: 38px; border-radius: 50%; background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.pctl .big:hover { background: var(--acc); color: var(--acc-ink); filter: brightness(1.08); }
.pctl .big .ic { width: 18px; height: 18px; }
.pctl .add { border-color: var(--line2); }
.pctl .add.on { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }
#vol { width: 70px; margin-left: 4px; }

/* ползунки */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 14px; margin: 0; cursor: pointer; --p: 0%; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 99px; background: linear-gradient(90deg, var(--acc) var(--p), var(--line2) var(--p)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); opacity: 0; transition: opacity .12s; }
input[type=range]:hover::-webkit-slider-thumb, input[type=range]:active::-webkit-slider-thumb { opacity: 1; }
#seek::-webkit-slider-runnable-track { height: 4px; border-radius: 0; }
#vol::-webkit-slider-thumb { opacity: 1; }

/* ---------- заглушка во вкладке, когда плеер вынесен ---------- */
.away { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); text-align: center; padding: 20px; }
.away .ic { width: 40px; height: 40px; color: var(--acc); }

.brand { display: none; }

/* ---------- большой экран: релизы слева, плейлист всегда справа, всё крупнее ---------- */
@media (min-width: 1000px) {
  html, body { font-size: 15px; }
  #app { display: grid; grid-template-columns: minmax(0, 1fr) clamp(360px, 30vw, 460px); grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .top { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 28px; }
  .top .bar { display: contents; }
  .brand { display: inline-flex; align-items: center; gap: 8px; order: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin-right: 8px; }
  .brand-ic { color: var(--acc); }
  .brand-ic .ic { width: 22px; height: 22px; }
  #mode { order: 1; }
  #mode button { height: 32px; padding: 0 14px; font-size: 13px; }
  #views { display: none; }
  #searchForm { order: 2; flex: 1 1 360px; max-width: 760px; }
  .search #q { height: 42px; font-size: 16px; }
  .search .primary { height: 42px; padding: 0 22px; font-size: 14px; }
  .bar-r { order: 3; }
  .bar-r .ib { width: 38px; height: 38px; }
  .bar-r .ic { width: 18px; height: 18px; }
  #srcs { order: 4; flex-basis: 100%; }
  #app.collapsed .top { padding: 10px 28px; }
  #app.collapsed .curq { font-size: 14px; }

  #app #searchView, #app #libView { display: flex !important; }
  #searchView { grid-column: 1; }
  #libView { grid-column: 2; border-left: 1px solid var(--line); background: var(--bg2); }
  #libView::before { content: attr(data-title); padding: 16px 20px 4px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  #toast { grid-column: 1 / -1; }
  .player { grid-column: 1 / -1; }

  .tools { padding: 10px 28px; gap: 8px; }
  #libView .tools { padding: 10px 20px; }
  .years { padding: 8px 28px; }
  .years button { height: 26px; font-size: 12px; padding: 0 11px; }
  .summary { padding: 10px 30px 0; font-size: 12px; }
  .list { padding: 0 28px 20px; }
  #libList { padding: 0 20px 20px; }
  .year > h2 { margin: 0 -28px; padding: 18px 30px 8px; font-size: 26px; }
  .year > h2 small { font-size: 13px; }
  .rel { margin-top: 10px; border-radius: 12px; }
  .rel-h { gap: 16px; padding: 12px; }
  .rel-h img { width: 76px; height: 76px; border-radius: 8px; }
  .rel-h b { font-size: 17px; }
  .rel-h small { font-size: 13px; margin-top: 5px; }
  .rel-h .pl { width: 42px; height: 42px; }
  .rel-h .pl .ic { width: 15px; height: 15px; }
  .tr { gap: 12px; padding: 8px 14px; }
  .tr .t b { font-size: 15px; }
  .tr .t small { font-size: 12.5px; }
  .pl, .add { width: 34px; height: 34px; }
  .pl .ic { width: 13px; height: 13px; }
  .add .ic { width: 16px; height: 16px; }
  .empty { padding: 80px 20px; font-size: 15px; }

  .progress { height: 16px; margin: -8px 0 -4px; }
  #seek::-webkit-slider-runnable-track { height: 5px; }
  .pinner { gap: 16px; padding: 10px 28px 14px; }
  .player img { width: 60px; height: 60px; border-radius: 8px; }
  .ptitle { font-size: 16px; }
  .psub { font-size: 13px; }
  .ptime { font-size: 13px; }
  .pctl { gap: 8px; }
  .pctl .ib { width: 40px; height: 40px; }
  .pctl .ib .ic { width: 20px; height: 20px; }
  .pctl .big { width: 52px; height: 52px; }
  .pctl .big .ic { width: 22px; height: 22px; }
  #vol { width: 120px; }
}

/* ---------- узкое окно ---------- */
@media (max-width: 520px) {
  .ptime, #vol { display: none; }
  .pinner { gap: 8px; padding: 5px 8px 7px; }
  .player img { width: 36px; height: 36px; }
  .pctl { gap: 2px; }
  .pctl .big { width: 34px; height: 34px; }
}
@media (max-width: 420px) {
  #plNew span, #playAll span, #libPlay span { display: none; }
  #plNew, #playAll, #libPlay { width: 28px; padding: 0; }
  .chk span { display: none; }
}
@media (max-width: 380px) {
  .seg button { padding: 0 7px; }
  .rel-h img { width: 40px; height: 40px; }
}
