*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: 10;
  --fg: 85;
  --bg-color: rgb(var(--bg), var(--bg), var(--bg));
  --border-color: rgb(calc(var(--bg) + 16), calc(var(--bg) + 16), calc(var(--bg) + 16));
  --text-color: rgb(var(--fg), var(--fg), var(--fg));
  --text-active: rgb(calc(var(--fg) + 68), calc(var(--fg) + 68), calc(var(--fg) + 68));
  --text-hover: rgb(calc(var(--fg) + 51), calc(var(--fg) + 51), calc(var(--fg) + 51));
  --text-ctrl: rgb(calc(var(--fg) - 17), calc(var(--fg) - 17), calc(var(--fg) - 17));
  --text-muted: rgb(calc(var(--fg) - 34), calc(var(--fg) - 34), calc(var(--fg) - 34));
  --text-dim: rgb(calc(var(--fg) - 51), calc(var(--fg) - 51), calc(var(--fg) - 51));
  --thumb-color: rgb(var(--fg), var(--fg), var(--fg));
}

html, body {
  height: 100%;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow: hidden;
}

.layout {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.divider {
  width: 1px;
  background: var(--border-color);
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
}

.divider::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  right: -4px;
}

.divider:hover,
.divider.dragging {
  background: var(--text-ctrl);
}

.site-name {
  padding: 16px 14px;
  color: var(--text-active);
  font-size: 11px;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.track-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.track-list::-webkit-scrollbar {
  width: 4px;
}

.track-list::-webkit-scrollbar-track {
  background: transparent;
}

.track-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.track {
  padding: 4px 14px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  transition: color 0.15s;
}

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

.track.active {
  color: var(--text-active);
}

.track.empty {
  cursor: default;
  color: var(--text-dim);
  font-style: italic;
}

/* ── Main Panel ── */

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 24px;
  min-width: 0;
}

.now-playing {
  flex-shrink: 0;
}

.label {
  color: var(--text-ctrl);
  font-size: 10px;
  margin-bottom: 4px;
}

.track-name {
  color: var(--text-active);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}

.track-name-inner {
  display: inline-block;
  padding-right: 4em;
}

.track-name.scrolling .track-name-inner {
  animation: marquee var(--marquee-duration, 10s) linear infinite;
}

@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── Player ── */

.player {
  flex-shrink: 0;
}

.time-display {
  color: var(--text-ctrl);
  font-size: 10px;
  margin-bottom: 8px;
}

.progress-bar {
  height: 2px;
  background: var(--border-color);
  margin-bottom: 12px;
  cursor: pointer;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  bottom: -6px;
}

.progress-fill {
  height: 100%;
  background: var(--text-ctrl);
  width: 0%;
  transition: width 0.1s linear;
}

.controls {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
}

.control {
  background: none;
  border: none;
  color: var(--text-ctrl);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.control:hover {
  color: var(--text-active);
}

.control.active {
  color: var(--text-active);
}

.volume {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.volume-label {
  color: var(--text-ctrl);
  font-size: 9px;
  min-width: 42px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 60px;
  height: 2px;
  background: var(--border-color);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 8px;
  height: 8px;
  background: var(--thumb-color);
  border-radius: 50%;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 8px;
  height: 8px;
  background: var(--thumb-color);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.modes {
  display: flex;
  gap: 10px;
}

.mode {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 9px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

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

.mode.active {
  color: var(--text-color);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Config Panel ── */

.config-panel {
  display: none;
  margin-top: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border-color);
}

.config-panel.open {
  display: block;
}

.config-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.config-label {
  color: var(--text-ctrl);
  font-size: 9px;
  min-width: 28px;
}

.config-value {
  color: var(--text-dim);
  font-size: 9px;
  min-width: 20px;
  text-align: right;
}

.config-panel input[type="range"] {
  width: 100px;
}

/* ── Mobile ── */

@media (max-width: 600px) {
  html, body {
    height: 100dvh;
    overflow: hidden;
  }

  .layout {
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  .sidebar {
    width: 100% !important;
    border-bottom: none;
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  .divider {
    display: none;
  }

  .panel {
    flex: 0;
    padding: 10px 16px;
    flex-shrink: 0;
    justify-content: flex-end;
    gap: 4px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
  }

  .now-playing {
    margin-bottom: 4px;
  }

  .now-playing .label {
    display: none;
  }

  .track-name {
    font-size: 11px;
  }
}
