:root {
  --bg: #0d0f12;
  --bg-elev: #15181d;
  --bg-elev-2: #1d2128;
  --line: #272c34;
  --text: #e8eaed;
  --muted: #9198a3;
  --accent: #7bd88f;
  --accent-dim: #4e9c62;
  --danger: #f2707b;
  --warn: #f0c469;
  --radius: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --player-h: 90px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }
#app { min-height: 100%; }

/* ---------------------------------------------------------------- вход */

.auth-wrap { display: grid; place-items: center; padding: 40px 20px; min-height: 100vh; }
.auth-card { width: min(420px, 100%); }
.tabs-switch { display: flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: 9px;
  border: 1px solid var(--line); margin-bottom: 20px; }
.tabs-switch button { flex: 1; background: none; border: 0; padding: 8px; border-radius: 7px;
  color: var(--muted); cursor: pointer; }
.tabs-switch button.active { background: var(--bg-elev-2); color: var(--text); }

/* ---------------------------------------------------------------- оболочка */

.layout { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 1fr var(--player-h);
  grid-template-areas: "side main" "player player"; height: 100vh; }

aside.side { grid-area: side; background: var(--bg-elev); border-right: 1px solid var(--line);
  padding: 18px 14px; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; margin: 4px 8px 20px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 12px var(--accent-dim); }

.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav button { background: none; border: 0; text-align: left; padding: 9px 12px; border-radius: 8px;
  color: var(--muted); cursor: pointer; display: flex; align-items: center; gap: 10px; }
.side nav button:hover { background: var(--bg-elev-2); color: var(--text); }
.side nav button.active { background: var(--bg-elev-2); color: var(--text); }
.side .section { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: #5c636e; margin: 20px 10px 6px; font-weight: 600; }
.side .pl-item { font-size: 14px; padding: 7px 12px; }
.side .spacer { flex: 1; }
.side .who { font-size: 13px; color: var(--muted); padding: 10px 8px 4px; border-top: 1px solid var(--line); margin-top: 8px; }
.side .who b { color: var(--text); font-weight: 500; }

main.content { grid-area: main; overflow-y: auto; padding: 26px 30px 40px; }

/* ---------------------------------------------------------------- общие */

.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 18px; }
h1, h2, h3 { letter-spacing: -0.02em; margin: 0 0 4px; }
h1 { font-size: 24px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }

label.field { display: block; margin: 14px 0 0; }
label.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; outline: none; transition: border-color .15s; }
textarea { resize: vertical; min-height: 80px; font-family: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-dim); }
input::placeholder { color: #5c636e; }
input[type=search] { padding-left: 36px; background: var(--bg) url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%239198a3" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>') no-repeat 12px center; }

button.btn { padding: 9px 15px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-elev-2); cursor: pointer; transition: background .15s, border-color .15s; white-space: nowrap; }
button.btn:hover:not(:disabled) { border-color: #3a4149; background: #232830; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #0a1b0e; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #8ae59c; border-color: #8ae59c; }
button.ghost { background: none; border-color: transparent; }
button.danger { color: var(--danger); }
button.icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; padding: 0; font-size: 16px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

.msg { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 14px; display: none; }
.msg.show { display: block; }
.msg.error { background: rgba(242,112,123,.1); border: 1px solid rgba(242,112,123,.35); color: #ffb3ba; }
.msg.ok { background: rgba(123,216,143,.1); border: 1px solid rgba(123,216,143,.3); color: #a8ebba; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--accent); border-color: rgba(123,216,143,.4); background: rgba(123,216,143,.08); }
.pill.off { color: var(--danger); border-color: rgba(242,112,123,.35); background: rgba(242,112,123,.08); }
.pill.yt { color: #ff6b6b; border-color: rgba(255,107,107,.35); background: rgba(255,107,107,.08); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.hint { display: flex; gap: 7px; align-items: flex-start; margin-top: 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
code.invite { font-family: ui-monospace, Menlo, monospace; background: var(--bg); border: 1px solid var(--line);
  padding: 3px 7px; border-radius: 5px; letter-spacing: .06em; cursor: pointer; }
.segmented { display: inline-flex; gap: 2px; background: var(--bg); padding: 3px; border-radius: 9px; border: 1px solid var(--line); }
.segmented button { background: none; border: 0; padding: 7px 14px; border-radius: 7px; color: var(--muted); cursor: pointer; font-size: 14px; }
.segmented button.active { background: var(--bg-elev-2); color: var(--text); }

/* ---------------------------------------------------------------- треки */

.track-list { display: flex; flex-direction: column; gap: 1px; }
.track { display: grid; grid-template-columns: 48px 1fr auto auto; gap: 14px; align-items: center;
  padding: 8px 10px; border-radius: 8px; transition: background .12s; position: relative; }
.track:hover { background: var(--bg-elev-2); }
.track.playing { background: rgba(123,216,143,.08); }
.track .cover { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--bg-elev-2); flex-shrink: 0; }
.track .meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.track .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 8px; align-items: center; }
.track.playing .title { color: var(--accent); }
.track .artist { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .dur { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.track .actions { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.track:hover .actions { opacity: 1; }
.track .actions button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: none;
  color: var(--muted); cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.track .actions button:hover { background: var(--bg-elev); color: var(--text); }
.track .actions button.fav-on { color: var(--accent); opacity: 1; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-top: 16px; }
.pl-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: border-color .15s, background .15s; }
.pl-card:hover { border-color: #3a4149; background: var(--bg-elev-2); }
.pl-card .pl-ico { font-size: 32px; margin-bottom: 12px; }
.pl-card .pl-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.pl-card .pl-info { font-size: 13px; color: var(--muted); }

.yt-card { display: flex; gap: 14px; align-items: center; padding: 10px; border-radius: 8px; background: var(--bg-elev);
  border: 1px solid var(--line); transition: border-color .15s; cursor: pointer; }
.yt-card:hover { border-color: #3a4149; }
.yt-card img { width: 120px; height: 68px; border-radius: 6px; object-fit: cover; background: var(--bg); }
.yt-card .meta { flex: 1; min-width: 0; }
.yt-card .title { font-weight: 500; margin-bottom: 4px; }
.yt-card .channel { font-size: 13px; color: var(--muted); }
.yt-card + .yt-card { margin-top: 12px; }

/* ---------------------------------------------------------------- плеер */

.player { grid-area: player; background: var(--bg-elev); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; padding: 0 24px; }
.player .now { display: flex; align-items: center; gap: 14px; min-width: 0; }
.player .now img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--bg-elev-2); }
.player .now .t { min-width: 0; }
.player .now .t .n { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .now .t .a { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .center { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(540px, 45vw); }
.player .controls { display: flex; align-items: center; gap: 16px; justify-content: center; }
.player .controls button { background: none; border: 0; color: var(--text); cursor: pointer; font-size: 18px;
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; transition: background .12s; }
.player .controls button:hover { background: var(--bg-elev-2); }
.player .controls button.play { background: var(--accent); color: #0a1b0e; font-size: 22px; width: 44px; height: 44px; }
.player .controls button.play:hover { background: var(--accent-dim); }
.player .controls button.on { color: var(--accent); }
.player .timeline { width: 100%; display: flex; align-items: center; gap: 10px; }
.player .timeline .time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; }
.player .timeline .time.right { text-align: right; }
.player .seek { flex: 1; height: 4px; background: var(--bg); border-radius: 2px; position: relative; cursor: pointer; }
.player .seek .bar { height: 100%; background: var(--accent); border-radius: 2px; position: relative; }
.player .seek .bar::after { content: ''; position: absolute; right: -6px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; background: var(--text); border-radius: 50%; opacity: 0; transition: opacity .12s; }
.player .seek:hover .bar::after { opacity: 1; }
.player .right { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.player .vol { display: flex; align-items: center; gap: 8px; }
.player .vol button { width: 32px; height: 32px; font-size: 16px; }
.player .vol-slider { width: 90px; height: 4px; background: var(--bg); border-radius: 2px; position: relative; cursor: pointer; }
.player .vol-slider .bar { height: 100%; background: var(--accent); border-radius: 2px; }

.toast { position: fixed; bottom: 22px; right: 22px; background: var(--bg-elev-2); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 9px; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; transform: translateY(8px); font-size: 14px; z-index: 100; }
.toast.show { opacity: 1; transform: translateY(0); }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 200; display: grid; place-items: center;
  padding: 20px; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; max-width: min(600px, 90vw); max-height: 85vh; overflow-y: auto; animation: slideUp .2s; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.modal-head h2 { flex: 1; }
.modal-head button.close { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 24px;
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.modal-head button.close:hover { background: var(--bg-elev-2); color: var(--text); }
.yt-embed { width: 100%; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr var(--player-h);
    grid-template-areas: "side" "main" "player"; }
  aside.side { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side .section { display: none; }
  .side .spacer { display: none; }
  .player { grid-template-columns: 1fr; gap: 8px; padding: 12px 16px; }
  .player .now { gap: 10px; }
  .player .now img { width: 44px; height: 44px; }
  .player .right { justify-content: center; }
}

/* ---------------------------------------------------------------- иконка Play на обложке трека */

.cover-wrap { position: relative; width: 48px; height: 48px; flex-shrink: 0; border-radius: 6px; overflow: hidden; }
.cover-wrap .cover { width: 100%; height: 100%; }
.play-ov {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 16px; line-height: 1;
  opacity: 0.35; transition: opacity 0.15s, background 0.15s; cursor: pointer;
}
.track:hover .play-ov { opacity: 0.8; }
.play-ov:hover { opacity: 1; background: rgba(0, 0, 0, 0.6); }
.track.playing .play-ov { opacity: 1; background: rgba(123, 216, 143, 0.85); color: #0a1b0e; }

/* ---------------------------------------------------------------- развёрнутый плеер */

.player .now img.now-cover { cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
.player .now img.now-cover:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(0,0,0,.5); }

.expanded {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0, 0, 0, 0);
  display: flex; align-items: flex-end; justify-content: flex-start;
  padding: 0 0 calc(var(--player-h) + 8px) 16px;
  transition: background 0.26s ease;
}
.expanded.open { background: rgba(0, 0, 0, 0.45); }

.exp-card {
  position: relative; width: min(300px, calc(100vw - 32px));
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 16px 18px; box-shadow: var(--shadow);
  transform: translateY(40px) scale(0.92); opacity: 0;
  transition: transform 0.26s cubic-bezier(.2,.8,.2,1), opacity 0.2s;
}
.expanded.open .exp-card { transform: translateY(0) scale(1); opacity: 1; }

.exp-close {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,.35); border: 0; color: var(--text); font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
}
.exp-close:hover { background: rgba(0,0,0,.6); }

.exp-cover { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px; background: var(--bg-elev-2); display: block; }
.exp-title { margin-top: 14px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; word-break: break-word; }
.exp-artist { color: var(--muted); font-size: 14px; margin-top: 2px; }
.exp-controls { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 16px; }
.exp-controls button { background: none; border: 0; color: var(--text); font-size: 20px; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.exp-controls button:hover { background: var(--bg-elev-2); }
.exp-controls button.play { background: var(--accent); color: #0a1b0e; width: 52px; height: 52px; font-size: 22px; }
.exp-controls button.play:hover { background: #8ae59c; }

@media (max-width: 900px) {
  .expanded { padding: 0 0 calc(var(--player-h) + 8px) 0; justify-content: center; }
}

/* ---------------------------------------------------------------- оформление (настройки) */

.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 18px; margin-top: 14px; }
.color-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.color-pick { width: 44px; height: 30px; border: 0; background: none; padding: 0; cursor: pointer; }
.color-pick::-webkit-color-swatch-wrapper { padding: 0; }
.color-pick::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 6px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 2px solid; vertical-align: -2px; margin-right: 4px; }

/* ---------------------------------------------------------------- листание результатов */

.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.pager:empty { display: none; }

/* ---------------------------------------------------------------- загрузка трека */

.upload-modal { width: min(720px, 94vw); max-width: none; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 760px) { .upload-grid { grid-template-columns: 1fr; } }
.upload-grid input[type=file] { padding: 8px; font-size: 13px; }
.cover-box { aspect-ratio: 1 / 1; border-radius: var(--radius); background: var(--bg); border: 1px dashed var(--line);
  display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.cover-preview { width: 100%; height: 100%; object-fit: cover; display: none; }
.web-covers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; max-height: 210px; overflow-y: auto; }
.web-cover { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; overflow: hidden; }
.web-cover img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; }
.web-cover.picked { border-color: var(--accent); }
.web-cover:hover { border-color: var(--line); }

/* ---------------------------------------------------------------- удаление и галочки */

.track .actions button.danger:hover { color: #ff7b72; background: rgba(255, 123, 114, 0.12); }
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 14px; cursor: pointer;
  padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---------------------------------------------------------------- YouTube: поиск и избранное */

.yt-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.yt-actions .btn.fav-on { color: var(--accent); }
.h2.sub, h2.sub { font-size: 18px; margin: 24px 0 6px; }
.hint-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.hint-card p { margin: 6px 0 0; }
