/* Loading pieces reuse the site's paper, surface and blue action colors. */
.skeleton-block,
.skeleton-line {
  background: #e8e8ed;
  animation: loading-pulse 1.25s ease-in-out infinite alternate;
}

.skeleton-block { display: block; border-radius: 12px; }
.skeleton-line { display: block; width: 100%; height: 11px; border-radius: 999px; }
.skeleton-line.short { width: 58%; }

.loading-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.loading-card { min-width: 0; overflow: hidden; border-radius: 18px; background: var(--surface, #fff); }
.skeleton-media { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 0; background: #e8e8ed; animation: loading-pulse 1.25s ease-in-out infinite alternate; }
.loading-card-body { display: grid; gap: 12px; padding: 18px 20px 20px; }
.loading-detail > .loading-card { width: 100%; max-width: 340px; }
.loading-detail > .loading-card .skeleton-media { aspect-ratio: 16 / 9; }
.loading-detail > div:last-child { display: grid; align-content: start; gap: 14px; min-width: 0; }
.loading-prompt { display: grid; align-content: center; gap: 12px; min-height: 190px; padding: 18px; border-radius: 16px; background: var(--night, #000); }
.loading-prompt .skeleton-line { background: rgba(255, 255, 255, 0.13); }

.loading-detail { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; gap: clamp(26px, 4vw, 48px); }
.loading-detail-preview { width: 100%; aspect-ratio: 9 / 16; border-radius: 16px; background: #e8e8ed; animation: loading-pulse 1.25s ease-in-out infinite alternate; }
.loading-detail-copy { display: grid; gap: 14px; min-width: 0; }

.loading-sounds { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 16px; min-height: 132px; padding: 16px 20px; border-radius: 16px; background: var(--surface, #fff); }
.loading-sounds > div { display: grid; gap: 9px; min-width: 0; }
.loading-sounds .skeleton-circle { width: 44px; height: 44px; border-radius: 50%; }
.loading-sounds .skeleton-wave { height: 32px; border-radius: 6px; }

.load-status, .compare .media-notice { display: inline-flex; align-items: center; gap: 7px; color: var(--muted, #6e6e73); font-size: 12px; line-height: 1.25; }
.load-dot { display: inline-block; flex: none; width: 11px; height: 11px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: load-spin 0.8s linear infinite; }
.load-dot[hidden] { display: none; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.is-updating { opacity: 0.65; transition: opacity 0.14s ease; }
.load-error { padding: 18px 20px; border: 1px solid var(--hairline, #d2d2d7); border-radius: 16px; background: var(--surface, #fff); color: var(--muted, #6e6e73); }
.more:disabled { cursor: wait; opacity: 0.62; }
.usage dd { min-width: 3ch; }
.usage dd[aria-busy="true"] { color: transparent; background: rgba(255, 255, 255, 0.12); border-radius: 8px; animation: loading-pulse 1.25s ease-in-out infinite alternate; }

.library-directory { margin-top: 34px; border-top: 1px solid var(--hairline, #d2d2d7); }
.library-directory > summary { padding: 16px 2px; color: var(--muted, #6e6e73); font-size: 14px; cursor: pointer; }
.library-directory[open] > summary { color: var(--ink, #1d1d1f); }
.library-directory .directory-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 0 0 20px; }
.library-directory .directory-group { min-width: 0; padding: 16px; border: 1px solid var(--hairline, #d2d2d7); border-radius: 14px; background: var(--surface, #fff); }
.library-directory .directory-group h2 { margin: 0 0 8px; font-size: 17px; }
.library-directory .directory-group ul { display: grid; gap: 4px; margin: 0; padding-left: 18px; color: var(--muted, #6e6e73); font-size: 13px; }

.play.is-loading { cursor: progress; }
.play.is-loading::before { display: none; }
.play.is-loading::after { position: absolute; inset: 14px; border: 2px solid rgba(255, 255, 255, 0.55); border-top-color: #fff; border-radius: 50%; content: ""; animation: load-spin 0.8s linear infinite; }

.preview-pending { background-color: #e8e8ed; animation: preview-pulse 1.25s ease-in-out infinite alternate; }
.preview-ready { animation: none; background: transparent; }

.card, .shelf-item, .style-preview, .template-preview, .audio-pair > div { position: relative; }
.style-preview, .template-preview { overflow: hidden; }
.media-load-status { position: absolute; z-index: 4; top: 10px; left: 10px; max-width: calc(100% - 20px); padding: 6px 10px; border: 1px solid rgba(210, 210, 215, 0.85); border-radius: 980px; background: rgba(255, 255, 255, 0.92); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); pointer-events: none; }
.media-load-status[hidden] { display: none; }
.media-load-status.is-error:not(.is-passive) { pointer-events: auto; }
.media-load-message { min-width: 0; overflow-wrap: anywhere; }
.media-retry { flex: none; padding: 0; border: 0; background: transparent; color: var(--accent, #0071e3); font: 500 12px/1.25 var(--body, -apple-system, BlinkMacSystemFont, sans-serif); cursor: pointer; }
.media-retry:hover { text-decoration: underline; }
.media-retry:focus-visible { outline: 2px solid var(--accent, #0071e3); outline-offset: 3px; border-radius: 3px; }
.media-retry[hidden] { display: none; }

.compare .media-notice { position: absolute; z-index: 4; top: auto; right: auto; bottom: 12px; left: 12px; max-width: calc(100% - 24px); padding: 6px 10px; border: 1px solid rgba(210, 210, 215, 0.85); border-radius: 980px; background: rgba(255, 255, 255, 0.92); }
.compare[aria-busy="true"] .media-notice::before { display: inline-block; flex: none; width: 10px; height: 10px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; content: ""; animation: load-spin 0.8s linear infinite; }
.compare .media-notice[hidden] { display: none; }
.compare.media-failed .spinner { display: none; }

@keyframes loading-pulse { from { opacity: 0.58; } to { opacity: 1; } }
@keyframes preview-pulse { from { background-color: #e8e8ed; } to { background-color: #f5f5f7; } }
@keyframes load-spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .loading-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .loading-detail { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .loading-cards { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-block, .skeleton-line, .skeleton-media, .loading-detail-preview, .skeleton-play, .skeleton-wave, .preview-pending, .load-dot, .play.is-loading::after, .compare .spinner, .compare[aria-busy="true"] .media-notice::before, .usage dd { animation: none; }
  .is-updating { transition: none; }
}

.audio-pair .media-load-status { position: relative; top: auto; left: auto; margin-top: 8px; }
