:root {
  color-scheme: dark;
  --bg: #12141a;
  --rail: #0e1015;
  --surface: #1a1d25;
  --surface-2: #21252f;
  --line: #2a2e3a;
  --ink: #e7e9f1;
  --muted: #8a90a4;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, .16);
  --on-accent: #fff;
  --danger: #f0566a;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 14px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.45 var(--sans); min-height: 100vh; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }

.grow { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.i-solid { fill: currentColor; }
.i-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.logo { display: block; width: 36px; height: 36px; border-radius: 10px; }
.logo.big { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 18px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* --- вход --- */
.login { max-width: 460px; margin: 16vh auto 0; padding: 0 24px; }
.login h1 { font-size: 40px; line-height: 1.1; margin: 0 0 14px; font-weight: 800; }
.login p { color: var(--muted); margin: 0 0 24px; }

/* --- каркас: боковая панель + содержимое --- */
.shell { display: flex; min-height: 100vh; }
.rail { position: relative; flex: none; width: 64px; }
.rail-panel {
  position: fixed; z-index: 20; top: 0; left: 0; bottom: 0; width: 64px; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px; padding: 14px 11px;
  background: var(--rail); border-right: 1px solid var(--line);
  transition: width .2s ease, box-shadow .2s ease;
}
/* наведение мышью (или клавиатурный фокус) выдвигает панель с подписями поверх содержимого */
.rail:hover .rail-panel, .rail:has(:focus-visible) .rail-panel { width: 232px; box-shadow: 10px 0 32px rgba(0, 0, 0, .5); }
.rail-brand { display: flex; align-items: center; gap: 14px; height: 42px; margin: 0 0 14px -1px; white-space: nowrap; }
.rail-brand .logo { flex: none; }
.rail-brand .lbl { font-size: 17px; font-weight: 800; }
.rail button {
  position: relative; width: 100%; height: 42px; flex: none; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  display: flex; align-items: center; gap: 14px; padding: 0 11px; cursor: pointer; text-align: left; white-space: nowrap;
}
.rail button svg { width: 20px; height: 20px; flex: none; }
.rail .lbl { opacity: 0; transition: opacity .15s ease; font-weight: 600; }
.rail:hover .lbl, .rail:has(:focus-visible) .lbl { opacity: 1; }
.rail button:hover { background: var(--surface-2); color: var(--ink); }
.rail button[aria-selected=true] { background: var(--accent-soft); color: var(--accent); }
.rail .count {
  position: absolute; top: 3px; left: 25px; min-width: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent);
  color: #fff; font-size: 10px; line-height: 17px; font-weight: 700; text-align: center;
}
@media (prefers-reduced-motion: reduce) { .rail-panel, .rail .lbl { transition: none; } }
.main { flex: 1; min-width: 0; padding: 0 22px 40px; max-width: 1480px; margin: 0 auto; }

/* --- шапка --- */
.top { display: flex; align-items: center; gap: 12px; padding: 16px 0; flex-wrap: wrap; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: .2px; margin-right: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 5px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--ink);
}
.pill img { border-radius: 50%; object-fit: cover; flex: none; }
.where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status[data-state=playing] .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.status[data-state=paused] .dot { background: var(--warn); }
.me { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.avatar { position: relative; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: var(--accent); flex: none; }
.avatar #avatar-ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* --- плитки --- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.tile-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tile-head svg { width: 15px; height: 15px; color: var(--accent); }
.tile-val { margin-top: 8px; font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-val small { margin-left: 6px; font-size: 14px; font-weight: 500; color: var(--muted); }
.tile-sub { margin-top: 6px; color: var(--muted); font-size: 12px; }
.meter { margin-top: 12px; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; }

/* --- кнопки и поля --- */
.btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px;
  padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); border-color: var(--line); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

input[type=text], select {
  border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 8px 12px; min-width: 0;
}
input[type=text]::placeholder { color: var(--muted); }
input[type=text]:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* --- раскладка --- */
.layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 14px; align-items: start; }
.side { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.panel { padding: 18px 20px 12px; }
.panel-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; }

/* --- плеер --- */
.deck { position: sticky; top: 16px; padding: 24px; }

.turntable { position: relative; width: min(100%, 290px); aspect-ratio: 1; margin: 0 auto; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 1.4; }
.ring-track { stroke: rgba(255, 255, 255, .1); }
.ring-fill { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 301.593; stroke-dashoffset: 301.593; }

.record {
  position: absolute; inset: 6%; border-radius: 50%;
  background:
    conic-gradient(from 25deg, transparent 0 8%, rgba(255,255,255,.10) 14%, transparent 22% 58%, rgba(255,255,255,.08) 64%, transparent 72%),
    repeating-radial-gradient(circle at center, #090a10 0 2px, #151823 2px 3px);
  animation: spin 5s linear infinite; animation-play-state: paused;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.turntable.spinning .record { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .record { animation: none; } }

.label {
  position: absolute; inset: 31%; border-radius: 50%; overflow: hidden; background: var(--accent);
  display: grid; place-items: center; font: 700 26px var(--sans); color: var(--on-accent);
}
.label img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.spindle { position: absolute; left: 50%; top: 50%; width: 6%; aspect-ratio: 1; margin: -3% 0 0 -3%; border-radius: 50%; background: var(--surface); }

.now { margin-top: 22px; text-align: center; }
.now h1 { font-size: 20px; line-height: 1.25; font-weight: 700; margin: 0; overflow-wrap: anywhere; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.progress { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); }

.controls { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover:not(:disabled) { border-color: var(--accent); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.big { width: 60px; height: 60px; background: var(--accent); color: #fff; border-color: var(--accent); }
.icon-btn.big:hover:not(:disabled) { filter: brightness(1.1); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.big svg { width: 26px; height: 26px; }
.icon-btn[data-mode=queue], .icon-btn[data-mode=track] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.icon-btn b { position: absolute; right: 6px; bottom: 6px; font-size: 10px; line-height: 1; }

.vol { display: flex; align-items: center; gap: 10px; margin-top: 20px; font-size: 13px; color: var(--muted); }
.vol input { flex: 1; accent-color: var(--accent); }
.vol output { width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; }

.extras { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.deck-btn { flex: 1 1 auto; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.deck-btn:hover:not(:disabled) { border-color: var(--accent); }
.deck-btn:disabled { opacity: .35; cursor: default; }

.notice { margin: 16px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 13px; }

/* --- правая часть --- */
.addbar { display: flex; gap: 8px; }
.addbar.card { padding: 12px; }
.addbar input { flex: 1; padding: 11px 14px; }
.addbar.slim input { padding: 8px 12px; }

.count { font-weight: 700; }

.listhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0 8px; }

.tracks { list-style: none; margin: 0; padding: 0; }
.tracks li {
  display: grid; grid-template-columns: 26px 44px minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 8px 6px; border-bottom: 1px solid var(--line); border-radius: 8px;
}
.tracks li:last-child { border-bottom: 0; }
.tracks li:hover { background: var(--surface-2); }
.tracks li.over { box-shadow: inset 0 2px 0 var(--accent); }
.tracks li.dragging { opacity: .4; }
.tracks li[draggable=true] { cursor: grab; }
.idx { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.cover { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.cover.ph { display: grid; place-items: center; color: var(--muted); }
.info { min-width: 0; }
.info .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.info .t a { text-decoration: none; }
.info .t a:hover { text-decoration: underline; }
.info .m { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dur { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.acts { display: flex; gap: 2px; }
.mini { width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 17px; line-height: 1; }
.mini:hover { background: var(--line); color: var(--ink); }
.mini.del:hover { color: var(--danger); }

.empty { color: var(--muted); padding: 22px 6px; margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip small { opacity: .7; margin-left: 4px; }
.chip small.own { margin-left: 6px; }

.pl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.pl-head h2 { font-size: 20px; font-weight: 700; margin: 0 12px 0 0; overflow-wrap: anywhere; }
.pl-add { margin: 12px 0 4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(92vw, 520px); z-index: 10;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.toast.err { background: var(--danger); border-color: var(--danger); color: #fff; }

.results-box { margin: 10px 0 4px; padding: 4px 12px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.results-box .results { max-height: 60vh; overflow-y: auto; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; color: var(--muted); font-size: 13px; }
.results-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .acts .btn { padding: 5px 12px; }

.kind { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 600; vertical-align: 1px; }
.kind.studio { color: var(--accent); border-color: var(--accent); }

/* --- планшет и телефон --- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { display: block; padding-bottom: 66px; }
  .rail { width: auto; }
  .rail-panel, .rail:hover .rail-panel, .rail:has(:focus-visible) .rail-panel {
    top: auto; bottom: 0; right: 0; width: auto; height: 58px; flex-direction: row; justify-content: space-around;
    padding: 8px 12px; border-right: 0; border-top: 1px solid var(--line); box-shadow: none;
  }
  .rail-brand, .rail .lbl, .rail .grow { display: none; }
  .rail button { width: 42px; justify-content: center; padding: 0; }
  .rail .count { left: auto; right: 2px; }
  .main { padding: 0 14px 24px; }
  .layout { grid-template-columns: 1fr; }
  .deck { position: static; }
  .top { gap: 8px; }
  .brand { width: 100%; margin: 0; }
  .me { margin-left: auto; }
  .tiles { gap: 10px; }
  .tile { padding: 12px 14px; }
  .tile-val { font-size: 24px; }
  .tracks li { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .tracks li .idx, .tracks li .dur { display: none; }
  .addbar input { font-size: 16px; }
  .toast { bottom: 76px; }
}
