:root {
  --bg: #14161a;
  --panel: #1d2026;
  --panel2: #262b34;
  --text: #e6e8ec;
  --muted: #8b93a1;
  --accent: #03a01d;
  --accent2: #028017;
  --on-accent: #04150a;
  --error: #e06c5f;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--error); min-height: 1.2em; }

/* ---------- top bar ---------- */

#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid #000;
}

.brand { font-weight: 700; letter-spacing: 0.3px; color: var(--accent); }

.now-playing {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

/* ---------- main ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13.5px;
  color: var(--muted);
}

input:not([type="range"]), select {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid #000;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14.5px;
  accent-color: var(--accent);
}

input[type="range"] {
  accent-color: var(--accent);
}

button {
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: var(--accent2); }

/* ---------- login ---------- */

#view-login .card {
  max-width: 380px;
  margin: 8vh auto 4vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#view-login h1 { margin: 0; font-size: 24px; }
#view-login p.muted { margin: 0; }

/* ---------- library ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

/* right-hand column: the tabbed DSP card (M9) */
.side-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* library column + toolbar */

.library-col { min-width: 0; }

.lib-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.lib-toolbar label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.lib-toolbar select {
  width: auto;
  padding: 6px 10px;
  font-size: 13.5px;
}

/* expandable directory tree */

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }

.tree-children { padding-left: 16px; border-left: 1px solid #2a2f38; margin-left: 8px; }

.tree-node.collapsed > .tree-children { display: none; }

.folder-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 7px 8px;
  border-radius: 8px;
}

.folder-head:hover { background: var(--panel2); }

.folder-head .chev {
  display: inline-block;
  width: 12px;
  color: var(--muted);
  transition: transform 0.12s ease;
}

.tree-node.collapsed > .folder-head .chev { transform: rotate(-90deg); }

.folder-head .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.tracks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tracks button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  font-weight: 400;
  padding: 8px 10px;
  border-radius: 8px;
}

/* track row: [number] [title + artist] [duration] */
.tracks .track {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.track-no {
  color: var(--muted);
  font-size: 12px;
  min-width: 1.6em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.track-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.track-main .track-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-sub {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-dur {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tracks button:hover { background: var(--panel2); }
.tracks button.playing { color: var(--accent); }

/* ---------- DSP card (M9 tabs) ---------- */

#dsp-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid #2a2f38;
}

.dsp-tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 10px;
  font-size: 13.5px;
}

.dsp-tab:hover { color: var(--text); }

.dsp-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.dsp-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dsp-panel p { margin: 0; }

.param {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: center;
  font-size: 13.5px;
}

.param label { grid-column: 1 / -1; }
.param input[type="range"] { grid-column: 1; }
.param .param-val {
  grid-column: 2;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.actions { display: flex; gap: 10px; }
.actions button { flex: 1; padding: 8px 10px; }

/* ---------- player bar ---------- */

#playerbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-top: 1px solid #000;
}

body:not(.logged-in) #playerbar { display: none; }

#playerbar button {
  padding: 7px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#playerbar button svg { display: block; }

/* play/pause: exactly one glyph at a time */
#play-pause .ic-pause { display: none; }
#play-pause.is-playing .ic-play { display: none; }
#play-pause.is-playing .ic-pause { display: block; }

/* repeat toggles: ghost. The SVG uses fill:currentColor, so `color` drives
   the icon — muted when off, accent (+ a faint fill) when on. */
#repeat-all, #repeat-one { background: transparent; color: var(--muted); }
#repeat-all:hover, #repeat-one:hover { background: var(--panel2); }
#repeat-all.active, #repeat-one.active { color: var(--accent); background: rgba(3, 160, 29, 0.14); }

.track-meta { min-width: 0; }

#track-title {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45vw;
}

#seek { flex: 1; }
#volume { width: 110px; }
#stream-state { white-space: nowrap; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; }

/* ---------- small screens ---------- */

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .track-title { max-width: 25vw; }
  #stream-state { display: none; }
}
