/* Song selection is a quiet list, separate from the animated playfield. */
dialog.song-library {
  width: min(780px, calc(100vw - 32px));
  max-width: none;
  max-height: min(800px, calc(100dvh - 40px));
  padding: 0;
  overflow: hidden;
  background: #111013;
  color: #f4eff2;
  border: 1px solid #51434c;
  border-radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: normal;
  text-transform: none;
}

dialog.song-library[open] { display: flex; flex-direction: column; }
.song-library *, .song-library *::before, .song-library *::after { box-sizing: border-box; }
.song-library button, .song-library input, .song-library select { font: inherit; letter-spacing: normal; text-transform: none; }
.song-library button { cursor: pointer; }
.song-library :is(button, input, select):focus-visible { outline: 2px solid #efa9ce; outline-offset: 3px; }
.song-library-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 26px 28px 18px; }
.song-library-header h2 { margin: 0; font-size: 28px; line-height: 1.25; font-weight: 650; letter-spacing: -0.035em; }
.song-library-header p { margin: 7px 0 0; color: #beb5bd; font-size: 14px; }
.song-library-close { flex: none; min-height: 44px; padding: 8px 13px; border: 1px solid #65525e; border-radius: 6px; background: transparent; color: #f4eff2; }
.song-library-close:hover { background: #2b232a; }
.song-library-controls { display: grid; grid-template-columns: 1fr 185px; gap: 16px; padding: 0 28px 20px; }
.song-library-controls label { display: grid; gap: 6px; min-width: 0; color: #d3c8d0; font-size: 13px; }
.song-library-controls :is(input, select) { width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px; color: #f4eff2; border: 1px solid #65525e; border-radius: 6px; background: #19161b; font-size: 16px; }
.song-library-controls input::placeholder { color: #a99da5; }
.song-library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 28px 12px; border-bottom: 1px solid #3b3138; }
.song-library-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.song-library-filters button { min-height: 42px; padding: 8px 12px; border: 0; border-radius: 5px; background: transparent; color: #c1b6be; font-size: 14px; }
.song-library-filters button:hover { background: #252025; color: #fff; }
.song-library-filters button[aria-pressed="true"] { background: #38232f; color: #ffd4ea; }
.song-library-count { flex: none; color: #b8adb6; font-size: 13px; font-variant-numeric: tabular-nums; }
.song-library-list { flex: 1 1 auto; min-height: 0; margin: 0; padding: 0 14px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #725c6a #111013; list-style: none; }
.song-library-row { display: flex; align-items: stretch; padding: 0 5px; border-bottom: 1px solid #30282e; transition: background-color 120ms ease; }
.song-library-row:last-child { border-bottom: 0; }
.song-library-row.has-credit { flex-wrap: wrap; }
.song-library-credit { flex: 0 0 100%; display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 10px 14px; color: #bfb2bb; font-size: 12px; }
.song-library-credit > span, .song-library-credit > small { flex-basis: 100%; overflow-wrap: anywhere; }
.song-library-credit a { color: #efa9ce; text-underline-offset: 3px; }
.song-library-row:hover { background: #201a20; }
.song-library-row.is-current { background: #261d24; box-shadow: inset 2px 0 0 #efa9ce; }
.song-library-track { display: grid; grid-template-columns: minmax(0, 1fr) 95px 48px; align-items: center; gap: 20px; flex: 1; min-width: 0; padding: 15px 10px; border: 0; background: transparent; color: #f4eff2; text-align: left; }
.song-library-names { display: grid; gap: 3px; min-width: 0; }
.song-library-names strong { overflow-wrap: anywhere; font-size: 17px; font-weight: 600; line-height: 1.3; }
.song-library-names > span { color: #bfb2bb; font-size: 13px; }
.song-library-tempo, .song-library-duration { color: #d1c5ce; font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.song-library-favorite { flex: none; align-self: center; width: 46px; height: 46px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #c7b7c1; font-size: 27px !important; line-height: 1; }
.song-library-favorite:hover { background: #392931; }
.song-library-favorite[aria-pressed="true"] { color: #efa9ce; }
.song-library-row-actions { display: flex; align-items: center; gap: 3px; }
.song-library-remove { min-height: 44px; padding: 8px; border: 0; border-radius: 5px; background: transparent; color: #cbb9c5; font-size: 13px !important; }
.song-library-remove:hover { background: #392931; color: #ffd4ea; }
.song-library-remove:disabled { cursor: wait; opacity: 0.65; }
.song-library-empty { margin: 0; padding: 44px 28px; color: #d1c5ce; font-size: 16px; text-align: center; }
.song-library-empty[hidden] { display: none; }
.song-library-footer { flex: none; padding: 14px 28px; border-top: 1px solid #3b3138; background: #171319; }
.song-library-footer p { margin: 0; color: #bfb2bb; font-size: 13px; line-height: 1.5; }

@media (max-width: 560px) {
  dialog.song-library { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .song-library-header { gap: 12px; padding: 20px 18px 16px; }
  .song-library-header h2 { font-size: 25px; }
  .song-library-controls { grid-template-columns: minmax(0, 1fr) 145px; gap: 10px; padding: 0 18px 16px; }
  .song-library-controls :is(input, select) { padding: 10px 8px; }
  .song-library-toolbar { align-items: flex-start; flex-direction: column; gap: 4px; padding: 0 14px 10px; }
  .song-library-count { padding-left: 8px; }
  .song-library-list { padding: 0 7px; }
  .song-library-track { grid-template-columns: minmax(0, 1fr) auto; column-gap: 9px; row-gap: 2px; padding: 13px 8px; }
  .song-library-names { grid-row: span 2; }
  .song-library-names strong { font-size: 16px; }
  .song-library-tempo, .song-library-duration { font-size: 12px; }
  .song-library-row-actions { flex-direction: column; justify-content: center; gap: 0; padding: 6px 0; }
  .song-library-footer { padding: 12px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  dialog.song-library[open] { animation: none; }
  .song-library-row { transition: none; }
}
