:root {
  --bg: #f4f0e8;
  --surface: #fffaf1;
  --surface-strong: #ffffff;
  --text: #1e2526;
  --muted: #697170;
  --line: rgba(30, 37, 38, 0.13);
  --accent: #0f9b8e;
  --accent-strong: #06786d;
  --accent-soft: rgba(15, 155, 142, 0.14);
  --coral: #f26b5f;
  --amber: #d99b2b;
  --shadow: 0 24px 70px rgba(23, 29, 29, 0.18);
  --button-shadow: 0 14px 30px rgba(15, 155, 142, 0.22);
  color-scheme: light;
}

body.dark {
  --bg: #151715;
  --surface: #20251f;
  --surface-strong: #2b3129;
  --text: #f7f2e9;
  --muted: #a9b1aa;
  --line: rgba(247, 242, 233, 0.14);
  --accent: #4bd6c7;
  --accent-strong: #8ee8df;
  --accent-soft: rgba(75, 214, 199, 0.16);
  --coral: #ff8b7e;
  --amber: #f0bd54;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  --button-shadow: 0 14px 32px rgba(75, 214, 199, 0.16);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(242, 107, 95, 0.16), transparent 30rem),
    linear-gradient(135deg, var(--bg), #e8f0ec 58%, #f5efe2);
  transition: background 220ms ease, color 220ms ease;
}

body.dark {
  background:
    radial-gradient(circle at top left, rgba(242, 107, 95, 0.15), transparent 30rem),
    linear-gradient(135deg, var(--bg), #1c211b 58%, #121412);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-columns: minmax(320px, 0.94fr) minmax(340px, 1.06fr);
  gap: 16px;
  align-items: stretch;
}

.player-panel,
.library-panel {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.player-panel {
  border-radius: 8px;
  padding: clamp(20px, 4vw, 34px);
  display: grid;
  grid-template-rows: auto auto auto auto auto auto 1fr;
  gap: 22px;
  overflow: hidden;
}

.library-panel {
  border-radius: 8px;
  padding: clamp(18px, 3vw, 28px);
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 18px;
  min-height: 0;
}

.topbar,
.library-header,
.time-row,
.volume-panel,
.filter-row,
.track-row,
.track-meta-line,
.top-actions {
  display: flex;
  align-items: center;
}

.topbar,
.library-header,
.time-row,
.track-row {
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.04;
}

.library-header h2 {
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.top-actions {
  gap: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.icon-button:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--accent-strong);
}

.icon-button:active {
  transform: translateY(0);
}

.icon-button.active,
.chip.active,
.track-row.active .track-index {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.icon-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.artwork-wrap {
  position: relative;
  width: min(100%, 390px);
  aspect-ratio: 1;
  margin: 0 auto;
}

.cover-art {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  box-shadow: 0 26px 60px rgba(20, 25, 24, 0.32);
  transition: transform 300ms ease, filter 300ms ease;
}

.player-panel.playing .cover-art {
  transform: scale(1.015);
}

.vinyl-disc {
  position: absolute;
  inset: 11% -13% 11% auto;
  width: 48%;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--surface-strong) 0 8%, var(--accent) 9% 11%, transparent 12%),
    repeating-radial-gradient(circle, #151816 0 3px, #2f3631 4px 7px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 18px 40px rgba(0, 0, 0, 0.28);
  opacity: 0.82;
  transform: translateX(-12%);
  transition: transform 300ms ease;
}

.player-panel.playing .vinyl-disc {
  animation: spin 9s linear infinite;
  transform: translateX(0);
}

@keyframes spin {
  to {
    transform: translateX(0) rotate(360deg);
  }
}

.track-details {
  text-align: center;
}

.track-kicker {
  color: var(--coral);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.track-details h2 {
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

#trackArtist {
  margin-top: 8px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.track-details .playback-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  font-size: 0.78rem;
  font-weight: 850;
}

.timeline {
  display: grid;
  gap: 10px;
}

.time-row {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.range {
  --value: 0%;
  width: 100%;
  height: 8px;
  appearance: none;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent) 0 var(--value), rgba(127, 133, 129, 0.24) var(--value) 100%);
  cursor: pointer;
  outline: none;
}

.range::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-strong);
  border: 5px solid var(--accent);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18);
}

.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 5px solid var(--accent);
  border-radius: 50%;
  background: var(--surface-strong);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18);
}

.controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(42px, 1fr));
  gap: 10px;
  align-items: center;
}

.control-main {
  width: 50px;
  height: 50px;
  justify-self: center;
}

.play-button {
  width: 62px;
  height: 62px;
  justify-self: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: var(--button-shadow);
}

.play-button:hover {
  color: #ffffff;
  filter: saturate(1.06);
}

.play-button svg {
  width: 25px;
  height: 25px;
  fill: currentColor;
}

.volume-panel {
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
  border: 1px solid var(--line);
}

.volume-panel .icon-button {
  flex: 0 0 auto;
}

.volume-panel span {
  min-width: 44px;
  text-align: right;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.88rem;
}

.visualizer {
  min-height: 88px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: end;
  gap: 8px;
  padding-top: 8px;
}

.visualizer span {
  height: calc(var(--bar, 20) * 1%);
  min-height: 10px;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, var(--coral), var(--amber) 52%, var(--accent));
  opacity: 0.42;
  transform-origin: bottom;
  transition: height 180ms ease, opacity 180ms ease;
}

.player-panel.playing .visualizer span {
  opacity: 0.82;
}

.track-count {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 800;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.search-box svg {
  width: 19px;
  height: 19px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-weight: 650;
}

.search-box input::placeholder {
  color: var(--muted);
}

.filter-row {
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
  transition: transform 180ms ease, color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.chip:hover {
  transform: translateY(-1px);
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.playlist {
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  scrollbar-color: var(--accent) transparent;
}

.track-row {
  gap: 12px;
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
  border: 1px solid var(--line);
  cursor: grab;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.track-row:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 10px 24px rgba(21, 24, 23, 0.08);
}

.track-row:active {
  cursor: grabbing;
}

.track-row.active {
  background: linear-gradient(90deg, var(--accent-soft), color-mix(in srgb, var(--surface-strong) 78%, transparent));
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.track-row.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.track-row.hidden {
  display: none;
}

.track-thumb {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
}

.track-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.track-copy strong,
.track-copy span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-copy strong {
  font-size: 0.98rem;
  line-height: 1.2;
}

.track-meta-line {
  gap: 8px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

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

.track-duration {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.track-index {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 900;
}

.favorite-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--coral);
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
  border-radius: 8px;
  border: 1px dashed var(--line);
  font-weight: 700;
}

@media (max-width: 900px) {
  .app-shell {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .library-panel {
    min-height: 520px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    margin: 10px auto;
    gap: 10px;
  }

  .player-panel,
  .library-panel {
    padding: 16px;
  }

  .topbar,
  .library-header {
    align-items: flex-start;
    gap: 12px;
  }

  .controls {
    grid-template-columns: repeat(6, minmax(32px, 1fr));
    gap: 6px;
  }

  .control-main,
  .control-toggle {
    width: min(44px, 100%);
    height: auto;
    aspect-ratio: 1;
    max-width: none;
  }

  .play-button {
    width: min(54px, 100%);
    height: auto;
    aspect-ratio: 1;
  }

  .volume-panel {
    align-items: center;
  }

  .track-row {
    padding: 10px;
    gap: 10px;
  }

  .track-thumb {
    width: 50px;
    height: 50px;
    flex-basis: 50px;
  }

  .track-index {
    display: none;
  }
}
