.bpm-finder { max-width: 760px; margin: 50px auto 0; }
.bpm-heading { margin-bottom: 20px; }
.bpm-description { margin: 8px 0 0; font-size: 14px; line-height: 21px; color: var(--muted); }
.bpm-heading h1 { margin: 0; font-size: 32px; }
.bpm-query-field { display: flex; align-items: center; gap: 4px; padding: 5px; border: 1px solid var(--color-neutral-300); border-radius: 12px; background: transparent; transition: border-color .15s, box-shadow .15s; }
.bpm-query-field:focus-within { border-color: var(--color-neutral-400); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-neutral-300) 28%, transparent); }
.bpm-region { flex-shrink: 0; }
.bpm-region-toggle { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border: 1px solid var(--color-neutral-200); border-radius: 8px; background: var(--color-white); font-size: 14px; font-weight: 500; }
.bpm-region-toggle > svg { width: 12px; height: 12px; }
.bpm-region-toggle:hover { border-color: var(--color-neutral-300); }
.bpm-region-panel { position: fixed; inset: auto; margin: 0; padding: 0; width: min(310px, calc(100vw - 24px)); max-height: 400px; overflow: hidden; border: 1px solid var(--color-neutral-200); border-radius: 14px; background: var(--color-white); color: var(--color-neutral-800); box-shadow: 0 12px 32px #0002; }
.bpm-region-panel:popover-open { display: flex; flex-direction: column; }
.bpm-region-search { padding: 10px; border-bottom: 1px solid var(--color-neutral-100); flex-shrink: 0; }
.bpm-region-search input { display: block; width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--color-neutral-200); border-radius: 8px; background: var(--color-neutral-50); color: inherit; font: inherit; font-size: 16px; outline: none; }
.bpm-region-search input:focus-visible { outline: none; border-color: var(--color-neutral-400); box-shadow: var(--elevation-focus); }
.bpm-region-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px; }
.bpm-region-list [role="option"] { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 20px; cursor: pointer; }
.bpm-region-list [role="option"] > span:nth-child(2) { flex: 1; }
.bpm-region-list [role="option"] > svg { width: 16px; height: 16px; flex-shrink: 0; visibility: hidden; }
.bpm-region-list [aria-selected="true"] { font-weight: 600; }
.bpm-region-list [aria-selected="true"] > svg { visibility: visible; }
.bpm-region-list [data-active], .bpm-region-list [role="option"]:hover { background: var(--color-neutral-100); }
.bpm-region-empty { margin: 0; padding: 20px 16px; color: var(--muted); font-size: 13px; text-align: center; }
.bpm-region-panel [hidden] { display: none; }
.bpm-query-field > input { appearance: none; -webkit-appearance: none; flex: 1; width: 100%; min-width: 0; margin: 0; border: 0; border-radius: 0; background: transparent; padding: 8px 10px; font-size: 16px; color: inherit; }
.bpm-query-field > input:focus, .bpm-query-field > input:focus-visible { outline: none; box-shadow: none; background: transparent; }
.bpm-query-field > input::-webkit-search-decoration { -webkit-appearance: none; }
.bpm-query-field .primary { flex-shrink: 0; min-height: 40px; margin-inline-start: 8px; }
.bpm-status:empty { display: none; }
.bpm-status { margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
.bpm-attribution { margin: 16px 0 0; font-size: 12px; line-height: 18px; color: var(--muted); }
.bpm-chart-title { margin: 8px 0 4px; font-size: 13px; line-height: 20px; font-weight: 600; color: var(--color-neutral-800); }
.bpm-chart-title[hidden] { display: none; }
.bpm-song-list { padding: 0; margin: 0; list-style: none; }
.bpm-song-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 96px; align-items: center; gap: 16px; height: 72px; border-bottom: 1px solid var(--color-neutral-100); }
.bpm-cover { width: 48px; height: 48px; position: relative; overflow: hidden; border-radius: 7px; background: var(--color-neutral-100); }
.bpm-cover img { width: 100%; height: 100%; object-fit: cover; }
.bpm-artwork-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 24px; }
.bpm-preview-button { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: inherit; display: grid; place-items: center; background: rgb(0 0 0 / 30%); color: white; padding: 0; }
.bpm-preview-icon { position: relative; width: 22px; height: 22px; filter: drop-shadow(0 1px 3px rgb(0 0 0 / 25%)); transition: transform 220ms cubic-bezier(.65, 0, .35, 1); }
.bpm-play-shape { fill: currentColor; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.bpm-preview-button:hover, .bpm-preview-button[aria-pressed="true"] { background: rgb(0 0 0 / 45%); }
.bpm-preview-button:focus-visible { outline: 2px solid white; outline-offset: -4px; }
.bpm-preview-button:disabled { opacity: .4; cursor: default; }
.bpm-playback-progress { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke-width: 2; visibility: hidden; pointer-events: none; }
.bpm-playback-track { stroke: rgb(255 255 255 / 30%); }
.bpm-playback-fill { stroke: white; stroke-dasharray: 100; stroke-dashoffset: 100; stroke-linecap: round; }
.bpm-song-row[data-preview="true"] .bpm-playback-progress { visibility: visible; }
.bpm-song-row[data-preview="true"] .bpm-preview-icon { transform: scale(.8182); }
.bpm-song-text { min-width: 0; }
.bpm-song-title { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; font-weight: 500; text-decoration: none; line-height: 21px; }
.bpm-song-title[href]:hover { text-decoration: underline; text-underline-offset: 3px; }
.bpm-song-text p { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; line-height: 18px; color: var(--muted); margin: 0; }
.bpm-action-slot { width: 96px; height: 52px; display: grid; grid-template-rows: 34px 5px; gap: 4px; justify-items: center; align-content: center; }
.bpm-value, .bpm-unavailable { width: 96px; height: 32px; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.bpm-progress[data-stage="queued"] { opacity: .45; }
.bpm-progress { grid-area: 1 / 1 / 3 / 2; align-self: center; display: grid; place-items: center; width: 32px; height: 32px; color: var(--color-neutral-600); }
.bpm-progress svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.bpm-progress-track { stroke: var(--color-neutral-200); }
.bpm-progress-fill { stroke-dasharray: 25 100; stroke-linecap: round; transform-origin: 12px 12px; animation: bpm-progress-spin 1s linear infinite; }
@keyframes bpm-progress-spin { to { transform: rotate(360deg); } }
.bpm-loading-unit { font-size: 10px; line-height: 12px; font-weight: 500; color: var(--muted); }
.bpm-number-skeleton { position: relative; display: block; flex-shrink: 0; width: 32px; height: 20px; overflow: hidden; border-radius: 5px; background: var(--color-neutral-200); }
.bpm-number-skeleton::after { content: ""; position: absolute; inset: -100%; background: linear-gradient(135deg, transparent 42%, rgb(250 250 250 / 80%) 50%, transparent 58%); transform: translate(-60%, -60%); animation: bpm-shimmer 3.6s linear infinite; }
.bpm-value { grid-area: 1 / 1; flex-direction: column; gap: 2px; height: 34px; font-family: inherit; font-variant-numeric: tabular-nums; font-size: 16px; line-height: 20px; font-weight: 600; }
.bpm-value span { display: block; font-size: 10px; line-height: 12px; font-weight: 500; color: var(--muted); }
.bpm-unavailable { grid-area: 1 / 1 / 3 / 2; align-self: center; color: var(--muted); }
.bpm-unavailable > svg { width: 16px; height: 16px; flex-shrink: 0; }
.bpm-unavailable[data-state="failed"] { color: var(--color-red-600); font-size: 11px; }
.bpm-unavailable[data-state="failed"] > span { min-width: 0; white-space: normal; overflow-wrap: anywhere; text-align: start; line-height: 14px; }
.bpm-beats { grid-area: 2 / 1; display: flex; gap: 5px; align-items: center; visibility: hidden; }
.bpm-beats[data-ready="true"] { visibility: visible; }
.bpm-beats span { width: 5px; height: 5px; border-radius: 50%; background: var(--color-neutral-200); }
.bpm-beats span[data-active] { background: var(--color-neutral-800); }
@media (max-width: 767px) {
  .bpm-finder { margin-top: 24px; }
  .bpm-heading { margin-bottom: 14px; }
  .bpm-heading h1 { font-size: 28px; }
  .bpm-query-field { gap: 0; }
  .bpm-query-field > input { padding-inline: 8px; font-size: 16px; }
  .bpm-region-toggle { padding-inline: 12px; gap: 6px; }
  .bpm-query-field .primary { padding-inline: 12px; }
  .bpm-song-row { grid-template-columns: 44px minmax(0, 1fr) 84px; gap: 12px; height: 68px; }
  .bpm-cover { width: 44px; height: 44px; }
  .bpm-action-slot, .bpm-value, .bpm-unavailable { width: 84px; }
  .bpm-song-text p { font-size: 11px; }
}

.bpm-search { position: sticky; top: var(--topbar-height); z-index: 21; width: 100%; margin: 0; padding-block: 8px; background: var(--color-white); }
#bpm-results { width: 100%; }
.bpm-song-row { scroll-margin-top: calc(var(--topbar-height) + 80px); }
.bpm-skeleton { position: relative; overflow: hidden; }
.bpm-skeleton-block, .bpm-skeleton-line { color: var(--color-neutral-200); fill: currentColor; }
.bpm-skeleton-block { display: block; background: var(--color-neutral-200); border-radius: 4px; }
.bpm-skeleton-text { display: grid; grid-template-rows: 21px 18px 18px; align-items: center; }
.bpm-skeleton-line { display: block; }
.bpm-skeleton::after { content: ""; position: absolute; inset: -100%; background: linear-gradient(135deg, transparent 42%, rgb(250 250 250 / 80%) 50%, transparent 58%); transform: translate(-60%, -60%); animation: bpm-shimmer 3.6s linear infinite; pointer-events: none; }
@keyframes bpm-shimmer { to { transform: translate(60%, 60%); } }
@media (prefers-reduced-motion: reduce) {
  .bpm-play-shape, .bpm-preview-icon { transition: none; }
  .bpm-progress-fill { animation: none; }
  .bpm-skeleton::after, .bpm-number-skeleton::after { animation: none; display: none; }
}
.bpm-search-control { position: relative; }
.bpm-search-control:has(.bpm-suggestions:not([hidden])) .bpm-query-field { border-radius: 12px 12px 0 0; border-color: var(--color-neutral-400); box-shadow: none; }
.bpm-suggestions { position: absolute; z-index: 20; inset: calc(100% - 1px) 0 auto; overflow-y: auto; overscroll-behavior: contain; padding: 6px; border: 1px solid var(--color-neutral-400); border-top-color: var(--color-neutral-200); border-radius: 0 0 12px 12px; background: var(--color-white); }
.bpm-suggestions[hidden], .bpm-suggestions [hidden] { display: none; }
.bpm-suggestions [role="option"] { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 10px 12px; border: 0; border-radius: 7px; background: transparent; color: inherit; text-align: start; font-size: 14px; }
.bpm-suggestions [role="option"] > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bpm-suggestions [role="option"] > small { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.bpm-suggestions [role="option"]:hover, .bpm-suggestions [aria-selected="true"] { background: var(--color-neutral-100); }
.bpm-suggestions > p { margin: 0; padding: 12px; font-size: 13px; color: var(--muted); }

.bpm-query-field > input::-webkit-search-cancel-button { appearance: none; -webkit-appearance: none; display: none; }
.bpm-clear { flex: 0 0 28px; display: grid; place-items: center; width: 28px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; }
.bpm-clear[hidden] { display: none; }
.bpm-clear svg { width: 20px; height: 20px; }
.bpm-clear circle { fill: var(--color-neutral-400); }
.bpm-clear path { fill: none; stroke: white; stroke-width: 1.6; stroke-linecap: round; }
.bpm-beats span[data-pulse] { animation: bpm-beat-pulse 260ms cubic-bezier(.16, 1, .3, 1); }
@keyframes bpm-beat-pulse { from { transform: scale(1.9); } to { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .bpm-beats span[data-pulse] { animation: none; } }
