:root {
  --bg: #121212;
  --panel: #1b1b1b;
  --panel-2: #242424;
  --line: #2e2e2e;
  --text: #ececec;
  --muted: #9a9a9a;
  --accent: #e0703f;
  --accent-text: #1a0d06;
  --danger: #ff6b6b;
  --bar-h: 88px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f4f1;
    --panel: #ffffff;
    --panel-2: #efebe6;
    --line: #e0dbd4;
    --text: #1d1b19;
    --muted: #6b665f;
    --accent: #c4552a;
    --accent-text: #ffffff;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* sign in */
.signin { display: grid; place-items: center; height: 100%; padding: 16px; }
.signin-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; max-width: 420px; width: 100%; }
.signin-card h1 { margin: 0 0 8px; }
.signin-card form { display: flex; gap: 8px; margin-top: 12px; }
.signin-card input { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); }
.signin-card button, .btn { padding: 9px 16px; border-radius: 8px; border: 0; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.error { color: var(--danger); min-height: 1.4em; }

/* layout */
.app { display: grid; grid-template-columns: 200px 1fr auto; grid-template-rows: 1fr var(--bar-h); height: 100%; }
.side { grid-row: 1; background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; }
.disc { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle, var(--accent) 0 28%, #111 30% 100%); box-shadow: inset 0 0 0 4px #222; }
.side a { text-decoration: none; padding: 8px 12px; border-radius: 8px; color: var(--muted); }
.side a:hover { background: var(--panel-2); color: var(--text); }
.side a.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 10px; }
.main { grid-row: 1; overflow-y: auto; min-width: 0; }
.top { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 14px 24px; border-bottom: 1px solid var(--line); }
.top input { width: 100%; max-width: 520px; padding: 9px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); }
.view { padding: 20px 24px 40px; }
.view h2 { margin: 4px 0 14px; font-size: 22px; }
.view h3 { margin: 26px 0 10px; font-size: 16px; color: var(--muted); font-weight: 600; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select { padding: 6px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 30px 0; }

/* grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
.card { cursor: pointer; min-width: 0; }
.card .art { width: 100%; aspect-ratio: 1; border-radius: 8px; object-fit: cover; background: var(--panel-2); display: block; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.card .art.round { border-radius: 50%; }
.card .t { margin-top: 8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card:hover .art { outline: 2px solid var(--accent); outline-offset: 2px; }

/* album page */
.album-head { display: flex; gap: 24px; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; }
.album-head img { width: 220px; height: 220px; border-radius: 10px; object-fit: cover; box-shadow: 0 10px 30px rgba(0,0,0,.35); background: var(--panel-2); }
.album-head .kind { text-transform: uppercase; font-size: 12px; letter-spacing: .08em; color: var(--muted); }
.album-head h1 { margin: 4px 0; font-size: 32px; line-height: 1.15; }
.album-head .by { font-size: 16px; }
.album-head .by a { text-decoration: none; color: var(--accent); }
.album-head .actions { display: flex; gap: 8px; margin-top: 14px; }
.tracks { width: 100%; border-collapse: collapse; }
.tracks td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tracks tr { cursor: pointer; }
.tracks tr:hover td { background: var(--panel); }
.tracks tr.playing td { color: var(--accent); font-weight: 600; }
.tracks .n { width: 40px; color: var(--muted); text-align: right; }
.tracks .d { width: 60px; color: var(--muted); text-align: right; }
.tracks .a { color: var(--muted); }
.tracks .add { width: 34px; text-align: center; color: var(--muted); }
.tracks .add button { background: none; border: 0; color: inherit; padding: 2px 6px; border-radius: 6px; }
.tracks .add button:hover { background: var(--panel-2); color: var(--text); }

/* devices */
.devices { display: grid; gap: 12px; max-width: 640px; }
.device { display: flex; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.device img { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; }
.device .info { flex: 1; min-width: 0; }
.device .name { font-weight: 600; }
.device .live { color: var(--accent); font-size: 12px; margin-left: 6px; }

/* drawer */
.drawer { grid-row: 1; grid-column: 3; width: 340px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.drawer-tabs { display: flex; gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); }
.drawer-tabs button { background: none; border: 0; padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.drawer-tabs button.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.drawer-tabs .icon { margin-left: auto; }
.drawer-body { overflow-y: auto; flex: 1; padding: 8px 10px 20px; }
.qitem { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 8px; cursor: pointer; }
.qitem:hover { background: var(--panel-2); }
.qitem.current { background: var(--panel-2); }
.qitem.current .qt { color: var(--accent); }
.qitem.past { opacity: .5; }
.qitem img { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; }
.qitem .qtext { min-width: 0; flex: 1; }
.qitem .qt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.qitem .qs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
.qitem .x { background: none; border: 0; color: var(--muted); padding: 4px 8px; border-radius: 6px; visibility: hidden; }
.qitem:hover .x { visibility: visible; }
.lyrics { padding: 10px 6px 40vh; }
.lyrics p { margin: 0; padding: 6px 4px; font-size: 17px; font-weight: 600; color: var(--muted); border-radius: 6px; cursor: pointer; transition: color .2s; }
.lyrics p.on { color: var(--text); }
.lyrics p:hover { background: var(--panel-2); }
.lyrics.plain p { cursor: default; color: var(--text); font-weight: 500; font-size: 15px; }
.lyrics .src { font-size: 12px; color: var(--muted); font-weight: 400; margin-bottom: 10px; }

/* player bar */
.bar { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(300px, 2fr) minmax(180px, 1fr); align-items: center; gap: 16px; padding: 0 18px; background: var(--panel); border-top: 1px solid var(--line); }
.now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.now img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--panel-2); cursor: pointer; }
.now img:not([src]) { visibility: hidden; }
.now-text { min-width: 0; }
.now-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.controls { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.buttons { display: flex; align-items: center; gap: 10px; position: relative; }
.icon { background: none; border: 0; padding: 6px 9px; border-radius: 50%; font-size: 17px; color: var(--muted); line-height: 1; }
.icon:hover { color: var(--text); background: var(--panel-2); }
.icon.on { color: var(--accent); }
.icon.play { background: var(--text); color: var(--bg); width: 40px; height: 40px; font-size: 16px; }
.icon.play:hover { background: var(--text); transform: scale(1.05); }
.quality { position: absolute; left: calc(100% + 10px); font-size: 11px; color: var(--muted); white-space: nowrap; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.quality:empty { display: none; }
.seek { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 640px; font-size: 12px; color: var(--muted); }
.seek input { flex: 1; }
.extras { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.extras input { width: 110px; }
input[type="range"] { accent-color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(var(--bar-h) + 16px); transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 10; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr var(--bar-h); }
  .side { grid-row: 1; flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand, .side-foot { display: none; }
  .main { grid-row: 2; }
  .drawer { position: fixed; inset: 0 0 var(--bar-h) 0; width: auto; z-index: 5; }
  .bar { grid-row: 3; grid-template-columns: 1fr auto; padding: 0 12px; }
  .extras { display: none; }
  .seek { display: none; }
  .quality { display: none; }
  .view, .top { padding-left: 16px; padding-right: 16px; }
}

/* devices (live) */
.devices { max-width: 760px; }
.device.is-playing { border-color: var(--accent); }
.device .dev-song { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-line { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.dev-progress { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.dev-fill { height: 100%; width: 0; background: var(--accent); transition: width .5s linear; }
.dev-time { font-size: 12px; white-space: nowrap; }
.dev-when { font-size: 12px; }
.dev-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.dev-ctl { display: flex; justify-content: center; }
.dev-btn { position: relative; }
.dot { position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
@media (max-width: 800px) { .device { flex-wrap: wrap; } .dev-actions { flex-direction: row; flex-wrap: wrap; } }
.btn:disabled { opacity: .45; cursor: default; }
.lyrics-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.lyrics-head .src { margin: 0; }
.timing-open { padding: 4px 10px; font-size: 12px; }
.timing { background: var(--panel-2); border-radius: 10px; padding: 8px; margin-bottom: 10px; display: grid; gap: 6px; }
.timing-row { display: flex; align-items: center; gap: 8px; }
.timing-value { flex: 1; text-align: center; font-weight: 700; font-size: 16px; }
.timing-hint { flex: 1; font-size: 12px; }
.timing .btn { padding: 5px 10px; font-size: 12px; }

/* get music and downloads */
.side-gap { height: 14px; }
.count { background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; margin-left: 6px; }
.get-form { display: flex; gap: 8px; max-width: 560px; margin-bottom: 14px; }
.get-form input { flex: 1; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.releases, .jobs { display: grid; gap: 10px; max-width: 820px; }
.release { display: flex; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.release.clickable { cursor: pointer; }
.release img, .release-art { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: var(--panel-2); flex: none; }
.release-info { flex: 1; min-width: 0; }
.release-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.release-files { margin-top: 8px; display: grid; gap: 2px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.badge { font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; color: var(--muted); }
.badge.warn { border-color: var(--danger); color: var(--danger); }
.badge.own { border-color: var(--accent); color: var(--accent); }
.small { font-size: 12px; }
.job { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.job-head { display: flex; align-items: center; gap: 10px; }
.job-name { flex: 1; font-weight: 600; min-width: 0; }
.job-actions { display: flex; gap: 6px; align-items: center; }
.job-actions .btn { padding: 5px 10px; font-size: 12px; }
.job-progress { margin: 8px 0 4px; }
.job-progress.busy .dev-fill { width: 30%; animation: busy 1.2s ease-in-out infinite; }
@keyframes busy { from { margin-left: -30%; } to { margin-left: 100%; } }
.tab { text-decoration: none; padding: 6px 14px; border-radius: 8px; color: var(--muted); }
.tab.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.link-badge { position: absolute; right: calc(100% + 10px); white-space: nowrap; font-size: 12px; border: 1px solid var(--accent); color: var(--accent); background: none; border-radius: 12px; padding: 2px 10px; }
.delay-box { max-width: 760px; margin-bottom: 16px; }
.delay-box input[type=range] { width: 100%; }

/* library switcher */
button.brand { background: none; border: 0; text-align: left; width: 100%; border-radius: 10px; }
button.brand:hover { background: var(--panel-2); }
.caret { color: var(--muted); font-size: 12px; margin-left: auto; }
.side { position: relative; }
.lib-menu { position: absolute; left: 10px; right: 10px; top: 52px; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.lib-item { display: flex; justify-content: space-between; gap: 12px; width: 100%; background: none; border: 0; padding: 8px 10px; border-radius: 8px; text-align: left; }
.lib-item:hover { background: var(--panel-2); }
.lib-item.active { color: var(--accent); }

/* The EDM library: synthwave night, cyan up front, violet and magenta behind. Always dark. */
:root[data-library="edm"] {
  --bg: #0b0716;
  --panel: #120a24;
  --panel-2: #1c1236;
  --line: #33284f;
  --text: #ede7ff;
  --muted: #a99cc9;
  --accent: #2ee6f2;
  --accent-text: #00363a;
  --violet: #b46cff;
  --magenta: #ff5fd2;
  color-scheme: dark;
}
:root[data-library="edm"] body { font-family: "Space Grotesk", "Segoe UI", system-ui, sans-serif; }
:root[data-library="edm"] .brand { font-family: "Audiowide", "Segoe UI", sans-serif; font-weight: 400; letter-spacing: 0.06em; }
:root[data-library="edm"] .disc { background: conic-gradient(from 200deg, var(--accent), var(--violet), var(--magenta), var(--accent)); box-shadow: 0 0 12px rgba(46, 230, 242, 0.55); }
:root[data-library="edm"] h1, :root[data-library="edm"] h2 { letter-spacing: 0.01em; }
:root[data-library="edm"] .card .art { box-shadow: 0 6px 22px rgba(123, 44, 255, 0.28); }
:root[data-library="edm"] .card:hover .art { box-shadow: 0 0 0 1px rgba(46, 230, 242, 0.5), 0 8px 26px rgba(46, 230, 242, 0.25); }
:root[data-library="edm"] .side a.active { color: var(--accent); }
