:root {
  --blue: #1f4e79;
  --green: #2e7d32;
  --amber: #b26a00;
  --red: #c62828;
  --bg: #f7f8fa;
  --border: #e0e3e8;
  --ink: #222;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--border);
}
h1 { font-size: 18px; margin: 0; color: var(--blue); }
h3 { font-size: 13px; color: #555; }
.tag { font-size: 11px; background: var(--blue); color: #fff; padding: 2px 8px; border-radius: 10px; vertical-align: middle; }
.spacer { flex: 1; }
.tabs { display: flex; gap: 6px; margin-left: 12px; }
.tab { background: transparent; color: #555; border: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
.tab.active { background: #eef2f8; color: var(--blue); font-weight: 600; }

main { padding: 24px; display: grid; gap: 20px; max-width: 980px; margin: 0 auto; }
.tabpane { display: grid; gap: 20px; }
.hidden { display: none; }

.panel { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
h2 { font-size: 15px; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.muted { color: #888; font-size: 13px; }
.err { color: var(--red); font-size: 13px; }
code { background: #f0f2f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: #ccc; display: inline-block; }
.dot.ok { background: var(--green); }
.dot.off { background: #d0d0d0; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.grid label { display: flex; flex-direction: column; font-size: 13px; gap: 4px; }
.grid label.wide, .grid h3.wide { grid-column: 1 / -1; }
.grid label.check { flex-direction: row; align-items: center; gap: 8px; }
.actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
input, select, button, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
button { background: var(--blue); color: #fff; border: none; cursor: pointer; }
button.ghost, a.ghost { background: #eef2f8; color: var(--blue); }
button.small, a.small { font-size: 12px; padding: 6px 10px; }
button:hover { opacity: .92; }

.result { background: #0f1720; color: #d6e2f0; border-radius: 8px; padding: 12px; margin-top: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; white-space: pre-wrap;
  word-break: break-word; max-height: 280px; overflow: auto; }
.result:empty { display: none; }
.result.big { max-height: 460px; }

.login-bg { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg,#eef2f8,#f7f8fa); }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 28px;
  width: 320px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.login-card h1 { font-size: 22px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.login-card button { margin-top: 6px; padding: 10px; }

/* Playlists */
.pl-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; margin-top: 10px; }
.pl-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 8px; max-height: 460px; overflow: auto; }
.pl-item { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.pl-item:hover { background: #f5f8fc; }
.pl-item.sel { background: #eef2f8; box-shadow: inset 3px 0 0 var(--blue); }
.pl-item small { color: #888; font-size: 11px; }
.badge { background: var(--blue); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 8px; align-self: flex-start; }
.pl-detail { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; min-height: 120px; }
.pl-detail h3 { margin: 0 0 4px; font-size: 16px; color: var(--blue); }
table.trk { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
table.trk th, table.trk td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.trk th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: #666; }

/* Playlist editor */
.ed-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ed-name { font-size: 15px; font-weight: 600; padding: 7px 10px; min-width: 200px; }
.ed-def { font-size: 13px; color: #555; display: flex; align-items: center; gap: 6px; }
.ed-add { display: flex; gap: 8px; margin: 12px 0 4px; }
.ed-add select { flex: 1; }
.ed-tracks { list-style: none; counter-reset: trk; margin: 6px 0 0; padding: 0; }
.ed-row { counter-increment: trk; display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; background: #fff; }
.ed-row::before { content: counter(trk); width: 22px; text-align: right; color: #999; font-size: 12px; }
.ed-title { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-len { color: #888; font-size: 12px; }
.ed-ctl { display: flex; gap: 4px; }
.ed-ctl button { padding: 3px 8px; font-size: 12px; background: #eef2f8; color: var(--blue); }
.ed-ctl button.danger { background: #fdecec; color: var(--red); }
.ed-ctl button:disabled { opacity: .4; cursor: default; }
@media (max-width: 760px) { .pl-layout { grid-template-columns: 1fr; } }

/* Library grid */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-top: 12px; }
.lib-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.lib-thumb { position: relative; aspect-ratio: 16/9; background: #0f1720; display: flex; align-items: center; justify-content: center; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lib-dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.72); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.lib-meta { padding: 8px 10px; }
.lib-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-meta small { color: #888; font-size: 11px; }
.lib-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 30px; opacity: 0; transition: opacity .15s; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.lib-card:hover .lib-play { opacity: 1; }

/* Modal player */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 10px; padding: 14px; width: min(880px, 96vw); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head span { font-weight: 600; }
