/* CLAUDE 10-06: Audio > Music library (musiclib.js). DESIGN-SYSTEM.md tokens as stocklib.css: surface #111113,
   surface-2 #161616, line #262626, accent #53fc18 (tint #15210f), text-faint #9a9a9a; 8 px controls, 10 px rows. */
.ml {
  display: grid;
  gap: 10px;
  min-width: 0;
  container-type: inline-size; /* the rows fold up when the tool panel is narrow (phones, 1024 px screens) */
}
.ml [hidden] {
  display: none !important;
}
.ml-setup {
  margin: 0;
}

/* the note about licences */
.ml-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 6px 10px 12px;
  border: 1px solid #263026;
  border-radius: 10px;
  background: #121612;
}
.ml-note p {
  flex: 1;
  margin: 0;
  color: #b3beb1;
  font-size: 12px;
  line-height: 1.45;
}
.ml-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -6px 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #bdbdbd;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.ml-x:hover {
  background: #1b221b;
  color: #eef3ed;
}

.ml-search input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  box-sizing: border-box;
}

/* categories: one row that scrolls sideways (the wheel scrolls it too), so the songs keep the panel's height */
.ml-cats {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding-bottom: 2px;
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.ml-cats.end {
  mask-image: none;
}
.ml-cats::-webkit-scrollbar {
  display: none;
}
.ml-cat {
  flex: none;
  scroll-snap-align: start;
}
.ml-cat {
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid #262626;
  border-radius: 999px;
  background: #161616;
  color: #bdbdbd;
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    background-color 150ms ease,
    transform 120ms ease-out;
}
.ml-cat[aria-pressed='true'] {
  border-color: #53fc18;
  background: #15210f;
  color: #eef3ed;
}
@media (hover: hover) and (pointer: fine) {
  .ml-cat:hover {
    border-color: #53fc18;
    color: #eef3ed;
  }
}
.ml-cat:active {
  transform: scale(0.97);
}

/* the songs */
.ml-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ml-list:empty {
  display: none;
}
.ml-row {
  --p: 0;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 6px 6px 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  transition:
    background-color 150ms ease,
    border-color 150ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .ml-row:hover {
    background: #161616;
  }
}
.ml-row.playing,
.ml-row[data-state='added'] {
  border-color: #262626;
  background: #161616;
}
/* the preview's progress, along the bottom of the row */
.ml-row::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: #53fc18;
  transform: scaleX(var(--p));
  transform-origin: left;
  opacity: 0;
}
.ml-row.playing::after {
  opacity: 1;
}

/* the cover is the play button */
.ml-cover {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(140deg, hsl(var(--h, 140) 55% 34%), hsl(calc(var(--h, 140) + 40) 60% 16%));
  color: #ffffffd9;
  cursor: pointer;
  overflow: hidden;
}
.ml-cover > svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 150ms ease;
}
/* play / pause / buffering, over the cover */
.ml-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000000a6;
  opacity: 0;
  transition: opacity 150ms ease;
}
.ml-icon::before {
  content: '';
  width: 0;
  height: 0;
  margin-left: 3px;
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent #fff;
}
.ml-row.playing .ml-icon::before {
  width: 4px;
  height: 14px;
  margin: 0;
  border-width: 0 4px;
  border-color: #fff;
}
.ml-row.playing[data-load='wait'] .ml-icon::before {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff40;
  border-top-color: #53fc18;
  border-radius: 50%;
  animation: ml-spin 700ms linear infinite;
}
.ml-row.playing .ml-icon,
.ml-cover:focus-visible .ml-icon {
  opacity: 1;
}
@media (hover: hover) and (pointer: fine) {
  .ml-cover:hover .ml-icon {
    opacity: 1;
  }
}
@media (hover: none) {
  .ml-icon {
    opacity: 1;
    background: none;
  }
  .ml-cover > svg {
    opacity: 0;
  }
}
.ml-cover:focus-visible,
.ml-use:focus-visible {
  outline: 3px solid #6dff3d;
  outline-offset: 2px;
}
.ml-cover:active {
  transform: scale(0.96);
}

.ml-text {
  flex: 1;
  display: grid;
  gap: 1px;
  min-width: 0;
}
.ml-text b,
.ml-text small,
.ml-lic {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ml-text b {
  color: #eef3ed;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}
.ml-text small {
  color: #9a9a9a;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}
.ml-lic {
  color: #7d8a79;
  font-size: 10.5px;
  line-height: 1.4;
}

/* Favorites' star (yours.js), in the row */
.ml-row > .fav-star {
  position: static;
  flex: none;
}
.ml-row:hover > .fav-star,
.ml-row:focus-within > .fav-star {
  opacity: 1;
}

.ml-use {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 56px;
  min-height: 34px;
  padding: 4px 12px;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  background: #1c1c1e;
  color: #eef3ed;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    transform 120ms ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .ml-use:hover {
    border-color: #53fc18;
  }
}
.ml-use:active {
  transform: scale(0.96);
}
.ml-use i {
  display: none;
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff40;
  border-top-color: #53fc18;
  border-radius: 50%;
  animation: ml-spin 700ms linear infinite;
}
.ml-row[data-state='adding'] .ml-use {
  cursor: progress;
}
.ml-row[data-state='adding'] .ml-use i {
  display: block;
}
.ml-row[data-state='added'] .ml-use {
  border-color: #53fc18;
  background: #15210f;
  color: #8dff66;
}
@keyframes ml-spin {
  to {
    transform: rotate(360deg);
  }
}

/* loading rows */
.ml-skel .ml-cover,
.ml-skel .ml-text i {
  background: linear-gradient(100deg, #161618 30%, #202023 50%, #161618 70%) 0 0 / 300% 100%;
  animation: ml-shimmer 1.2s ease-in-out infinite;
}
.ml-skel .ml-text i {
  display: block;
  height: 10px;
  border-radius: 4px;
}
.ml-skel .ml-text i + i {
  width: 55%;
  margin-top: 6px;
}
@keyframes ml-shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ml-skel .ml-cover,
  .ml-skel .ml-text i {
    animation: none;
  }
  .ml-use i,
  .ml-row.playing[data-load='wait'] .ml-icon::before {
    animation-duration: 1.6s;
  }
}

/* empty, error and offline */
.ml-msg {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px 12px;
  border: 1px dashed #262626;
  border-radius: 10px;
  text-align: center;
}
.ml-msg p {
  margin: 0;
  color: #bdbdbd;
  font-size: 13px;
  line-height: 1.45;
}
.ml-more {
  justify-self: center;
  min-height: 40px;
  padding: 6px 18px;
  border: 1px solid #262626;
  border-radius: 8px;
  background: #161616;
  color: #eef3ed;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.ml-foot {
  margin: 2px 0 0;
  color: #7a7a7a;
  font-size: 11px;
  line-height: 1.45;
}
.ml-foot a {
  color: #a9a9a9;
}

/* phones and touch: 44 px targets, the categories in one row that scrolls sideways, the star always there */
@media (max-width: 760px), (pointer: coarse) {
  .ml-cat,
  .ml-x,
  .ml-more,
  .ml-use,
  .ml-search input,
  .ml-msg .cc-chip {
    min-height: 44px;
  }
  .ml-x {
    width: 44px;
    height: 44px;
    margin: -10px -2px -10px 0;
  }
}
/* a narrow tool panel (a phone's is ~210 px, a 1024 px screen's less): the cover, star and Use on one line, the song's
   name, length and licence under them at full width */
@container (max-width: 240px) {
  .ml-row {
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 6px;
  }
  .ml-text {
    order: 3;
    flex-basis: 100%;
  }
  .ml-row > .fav-star {
    margin-left: auto;
  }
  .ml-use {
    margin-left: auto;
  }
  .ml-row > .fav-star + .ml-use {
    margin-left: 0;
  }
  .ml-note p,
  .ml-foot {
    font-size: 11px;
  }
}
