:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f1f2ee;
  --border: #e2e3dd;
  --border-strong: #d2d4cc;
  --text: #1d201c;
  --muted: #6c716a;
  --accent: #1f7a4d;
  --accent-soft: rgba(31, 122, 77, 0.1);
  --accent-contrast: #ffffff;
  --danger: #a4423a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 26, 20, 0.05), 0 8px 24px rgba(20, 26, 20, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121411;
    --surface: #191c18;
    --surface-2: #20241f;
    --border: #2a2f28;
    --border-strong: #39402f;
    --text: #e8eae2;
    --muted: #9aa295;
    --accent: #5cc48c;
    --accent-soft: rgba(92, 196, 140, 0.14);
    --accent-contrast: #10261a;
    --danger: #e08a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.24);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: 18px clamp(12px, 3vw, 28px) 28px;
}

h1,
p,
ol,
li {
  margin: 0;
  padding: 0;
}

ol {
  list-style: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

svg[hidden] {
  display: none;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 1220px;
  margin: 0 auto 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  position: relative;
  flex: none;
}

.mark::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-left: 9px solid var(--accent-contrast);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  transform: translateX(2px);
}

h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sub {
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.06);
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 384px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  max-width: 1220px;
  margin: 0 auto;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- playlist ---------- */

.playlist {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 120px);
}

.playlist-head {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.search {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px;
  outline: none;
}

.search:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search::-webkit-search-cancel-button {
  cursor: pointer;
}

.modes {
  display: flex;
  gap: 6px;
  flex: none;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 140ms ease;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.tracks {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}

.track {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: background 120ms ease;
}

.track:hover {
  background: var(--surface-2);
}

.track[aria-current="true"] {
  background: var(--accent-soft);
}

.track-missing .t-title {
  color: var(--muted);
}

.track-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: none;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.track-main:focus-visible,
.ytm:focus-visible,
.btn:focus-visible,
.chip:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.num {
  flex: none;
  width: 20px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.track[aria-current="true"] .num {
  color: var(--accent);
}

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

.t-title {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track[aria-current="true"] .t-title {
  color: var(--accent);
  font-weight: 600;
}

.t-artist {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ytm {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 8px;
  border-radius: 8px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
}

.track:hover .ytm,
.ytm:focus-visible {
  opacity: 1;
}

.ytm:hover {
  color: var(--accent);
  background: var(--surface);
}

.ytm svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty {
  padding: 24px 16px 28px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* equalizer marker for the playing row */
.bars {
  display: none;
  width: 20px;
  justify-content: flex-end;
  gap: 2px;
  align-items: flex-end;
  height: 13px;
}

.bars i {
  width: 2.5px;
  background: var(--accent);
  border-radius: 1px;
  animation: eq 900ms ease-in-out infinite;
}

.bars i:nth-child(1) {
  height: 60%;
  animation-delay: -200ms;
}
.bars i:nth-child(2) {
  height: 100%;
  animation-delay: -600ms;
}
.bars i:nth-child(3) {
  height: 40%;
  animation-delay: -400ms;
}

.track[data-playing="true"] .bars {
  display: flex;
}

.track[data-playing="true"] .num {
  display: none;
}

.track[data-paused="true"] .bars i {
  animation-play-state: paused;
}

@keyframes eq {
  0%,
  100% {
    transform: scaleY(0.45);
  }
  50% {
    transform: scaleY(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bars i {
    animation: none;
  }
}

/* ---------- stage ---------- */

.stage {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0d0f0c;
  border: 1px solid var(--border);
}

.frame iframe,
#player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.frame-idle {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: #b7bdb2;
  font-size: 13px;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, #1a1f19, #0d0f0c 70%);
  padding: 16px;
}

.frame-idle[hidden] {
  display: none;
}

.frame-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid #3a4238;
  position: relative;
}

.frame-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0;
  height: 0;
  border-left: 12px solid #b7bdb2;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  transform: translateX(2px);
}

.now {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.now-text {
  min-width: 0;
}

.now-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-artist {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-link {
  flex: none;
  font-size: 12.5px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  transition: background 140ms ease;
}

.now-link:hover {
  background: var(--accent-soft);
}

.seek,
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  width: 36px;
  flex: none;
}

.time:last-child {
  text-align: right;
}

.range {
  -webkit-appearance: none;
  appearance: none;
  height: 20px;
  background: transparent;
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
}

.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--fill, 0%),
    var(--border-strong) var(--fill, 0%),
    var(--border-strong) 100%
  );
}

.range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}

.range::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}

.range::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.icon-btn-main {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: var(--accent-contrast);
}

.icon-btn-main:hover {
  background: var(--accent);
  filter: brightness(1.06);
}

.icon-btn-main svg {
  width: 21px;
  height: 21px;
}

.controls #prevBtn,
.controls #nextBtn {
  color: var(--muted);
}

.volume {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex: 0 1 160px;
  min-width: 96px;
}

.icon-btn-sm {
  width: 30px;
  height: 30px;
}

.icon-btn-sm svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status {
  min-height: 16px;
  font-size: 12px;
  color: var(--muted);
}

.status[data-tone="err"] {
  color: var(--danger);
}

.hint {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 11px;
}

.hint strong {
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .stage {
    order: -1;
  }

  .playlist {
    max-height: none;
  }

  .tracks {
    max-height: 58vh;
  }
}

@media (max-width: 520px) {
  body {
    padding: 12px 10px 20px;
  }

  .topbar {
    margin-bottom: 12px;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1 1 auto;
  }

  .playlist-head {
    flex-wrap: wrap;
  }

  .search {
    flex-basis: 100%;
  }

  .now {
    flex-direction: column;
  }

  .ytm {
    opacity: 1;
  }
}
