/* ========== 动态谱展示页 ========== */
.sg-library-body {
    background: transparent;
}

.sg-library-main {
    position: relative;
    z-index: 1;
}

/* 分类标签横向滚动 */
.sg-library-tags-scroll {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(96, 165, 250, 0.4) transparent;
}

.sg-library-tags-scroll::-webkit-scrollbar {
    height: 6px;
}

.sg-library-tags-scroll::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.35);
    border-radius: 3px;
}

.sg-category-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    font-size: 1.0625rem;
    font-weight: 500;
    color: #cbd5e1;
    background: rgba(21, 45, 82, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sg-category-tag:hover {
    color: #fff;
    border-color: rgba(96, 165, 250, 0.45);
    background: rgba(30, 58, 102, 0.8);
}

.sg-category-tag.active {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

/* 视图切换 */
.sg-view-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #94a3b8;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sg-view-btn:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.06);
}

.sg-view-btn.active {
    color: #fff;
    background: rgba(59, 130, 246, 0.35);
}

/* 曲谱卡片 - 网格 */
.sg-score-grid-view {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1.25rem;
}

@media (min-width: 640px) {
    .sg-score-grid-view {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .sg-score-grid-view {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .sg-score-grid-view {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.sg-library-card {
    background: rgba(15, 33, 64, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.sg-library-card:hover,
.sg-library-card:focus {
    outline: none;
    transform: translateY(-4px);
    border-color: rgba(96, 165, 250, 0.35);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.sg-library-card-cover {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #152d52;
    overflow: hidden;
}

.sg-library-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
}

.sg-library-card-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sg-library-card:hover .sg-library-card-play {
    opacity: 1;
}

.sg-library-card-cat {
    position: absolute;
    left: 10px;
    top: 10px;
    padding: 4px 10px;
    font-size: 0.875rem;
    color: #e2e8f0;
    background: rgba(15, 33, 64, 0.85);
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.sg-library-card-body {
    padding: 1rem 1.125rem 1.125rem;
}

.sg-library-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #f8fafc;
    line-height: 1.4;
    margin: 0 0 0.375rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sg-library-card-author {
    font-size: 1rem;
    color: #94a3b8;
    margin: 0 0 0.625rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sg-library-card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1rem;
    color: #64748b;
}

.sg-library-card-tag {
    padding: 2px 8px;
    font-size: 0.875rem;
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 6px;
}

/* 列表视图 */
.sg-score-list-view {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sg-library-card--list {
    display: flex;
    flex-direction: row;
    align-items: center;
    min-height: 120px;
    overflow: hidden;
}

.sg-library-card--list:hover,
.sg-library-card--list:focus {
    transform: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.sg-library-card--list .sg-library-card-cover {
    flex-shrink: 0;
    width: 200px;
    height: 112px;
    min-width: 200px;
    min-height: 112px;
    max-height: 112px;
    aspect-ratio: auto;
    border-radius: 12px 0 0 12px;
    background: linear-gradient(135deg, #152d52 0%, #1e3a66 100%);
}

.sg-library-card--list .sg-library-card-cover img {
    width: 200px;
    height: 112px;
    object-fit: cover;
    object-position: center top;
}

.sg-library-card--list .sg-library-card-play {
    font-size: 1.75rem;
}

.sg-library-card--list .sg-library-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: 1rem 1.25rem;
    gap: 0.375rem;
}

.sg-library-card--list .sg-library-card-title {
    font-size: 1.375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.sg-library-card--list .sg-library-card-author {
    margin: 0;
    font-size: 1.0625rem;
}

.sg-library-card--list .sg-library-card-meta {
    margin-top: 0.25rem;
    gap: 1.25rem;
}

@media (max-width: 640px) {
    .sg-library-card--list {
        flex-direction: row;
        align-items: center;
        min-height: 96px;
    }

    .sg-library-card--list .sg-library-card-cover {
        width: 140px;
        height: 84px;
        min-width: 140px;
        min-height: 84px;
        max-height: 84px;
        border-radius: 12px 0 0 12px;
    }

    .sg-library-card--list .sg-library-card-cover img {
        width: 140px;
        height: 84px;
        object-position: center top;
    }

    .sg-library-card--list .sg-library-card-body {
        padding: 0.75rem 1rem;
    }

    .sg-library-card--list .sg-library-card-title {
        font-size: 1.125rem;
    }
}

/* 分页 */
.sg-page-btn {
    min-width: 48px;
    height: 48px;
    padding: 0 14px;
    font-size: 1.0625rem;
    color: #cbd5e1;
    background: rgba(21, 45, 82, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sg-page-btn:hover:not([disabled]) {
    color: #fff;
    border-color: rgba(96, 165, 250, 0.4);
    background: rgba(30, 58, 102, 0.9);
}

.sg-page-btn.active {
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border-color: transparent;
}

.sg-page-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.sg-page-ellipsis {
    color: #64748b;
    padding: 0 4px;
    font-size: 1.125rem;
}

/* 弹窗内加载 */
.sg-library-player-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 280px;
    font-size: 1.125rem;
    color: #94a3b8;
}

/* 弹窗播放器 */
#sgLibraryPreviewViewport {
    box-sizing: border-box;
}

#sgLibraryPreviewViewport #sgLibraryPreviewInner {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    overflow: hidden;
    box-sizing: border-box;
}

#sgLibraryPreviewInner .sg-img-player-root,
#sgLibraryPreviewInner .sg-img-player-scroll,
#sgLibraryPreviewInner .sg-img-player-wrap {
    width: 100%;
    height: 100%;
    max-width: none !important;
    box-sizing: border-box;
}

#sgLibraryPreviewInner .sg-img-player-stage {
    max-width: none !important;
}

/* 抵消 Tailwind Preflight 对谱面 img 的 max-width 干扰（展示页引入了 Tailwind） */
.sg-library-body #sgLibraryPreviewOverlay .sg-img-player-img {
    max-width: none !important;
}

#sgLibraryPreviewInner .sg-img-player-scroll {
    overflow: hidden !important;
    background: #0a0c10;
}

/* 仅全屏播放视口（非整个弹窗外壳） */
#sgLibraryPreviewViewport:fullscreen,
#sgLibraryPreviewViewport:-webkit-full-screen {
    position: relative;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    aspect-ratio: unset !important;
    display: block !important;
    background: #0a0c10 !important;
    overflow: hidden !important;
}

#sgLibraryPreviewViewport:fullscreen #sgLibraryPreviewInner,
#sgLibraryPreviewViewport:-webkit-full-screen #sgLibraryPreviewInner {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    background: #0a0c10;
    overflow: hidden;
}

#sgLibraryPreviewViewport:fullscreen .sg-img-player-root,
#sgLibraryPreviewViewport:-webkit-full-screen .sg-img-player-root,
#sgLibraryPreviewViewport:fullscreen .sg-img-player-scroll,
#sgLibraryPreviewViewport:-webkit-full-screen .sg-img-player-scroll,
#sgLibraryPreviewViewport:fullscreen .sg-img-player-wrap,
#sgLibraryPreviewViewport:-webkit-full-screen .sg-img-player-wrap {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    margin: 0 !important;
}

#sgLibraryPreviewViewport:fullscreen .sg-img-player-stage,
#sgLibraryPreviewViewport:-webkit-full-screen .sg-img-player-stage {
    margin: 0 !important;
}

/* ================================================================================
   动态谱展示页 v2 — 对齐首页深蓝暗紫 + 玻璃拟态
   ================================================================================ */

/* 页头 */
.sg-library-header-row {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .sg-library-header-row {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }
}

.sg-library-header-tag {
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    color: rgba(147, 197, 253, 0.85);
    letter-spacing: 0.04em;
}

.sg-library-header-title {
    margin: 0;
    font-size: clamp(1.875rem, 4vw, 2.25rem);
    font-weight: 800;
    color: #f8fafc;
    line-height: 1.2;
}

.sg-library-header-desc {
    margin: 0.75rem 0 0;
    max-width: 42rem;
    font-size: 1.125rem;
    line-height: 1.65;
    color: #cbd5e1;
}

.sg-library-search-wrap {
    width: 100%;
    flex-shrink: 0;
}

@media (min-width: 1024px) {
    .sg-library-search-wrap {
        width: 420px;
    }
}

.sg-library-search-box {
    position: relative;
}

.sg-library-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    opacity: 0.55;
    pointer-events: none;
}

.sg-library-search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    font-size: 1.125rem;
    color: #f8fafc;
    background-color: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.sg-library-search-input::placeholder {
    color: #94a3b8;
}

.sg-library-search-input:focus {
    border-color: rgba(147, 197, 253, 0.45);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* 筛选栏玻璃容器 */
.sg-library-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

@media (min-width: 640px) {
    .sg-library-filter-bar {
        flex-direction: row;
        align-items: center;
    }
}

.sg-library-filter-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sg-library-view-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.sg-library-sort-select {
    padding: 0.75rem 1rem;
    font-size: 1.0625rem;
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
    outline: none;
}

.sg-library-sort-select:focus {
    border-color: rgba(147, 197, 253, 0.45);
}

.sg-library-sort-select option {
    background: #0c1228;
    color: #f1f5f9;
}

/* 分类标签 */
.sg-library-body .sg-category-tag {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.sg-library-body .sg-category-tag:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(147, 197, 253, 0.35);
}

.sg-library-body .sg-category-tag.active {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.85), rgba(59, 130, 246, 0.75));
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}

/* 曲谱卡片 — 统一玻璃拟态 */
.sg-library-body .sg-library-card {
    background-color: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    border-radius: 16px;
    transition:
        transform 0.35s ease,
        background-color 0.35s ease,
        box-shadow 0.35s ease,
        border-color 0.35s ease;
}

.sg-library-body .sg-library-card:hover,
.sg-library-body .sg-library-card:focus {
    transform: translateY(-4px);
    background-color: rgba(255, 255, 255, 0.24);
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.sg-library-body .sg-library-card-title {
    color: #ffffff;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.sg-library-body .sg-library-card-author {
    color: #e2e8f0;
}

.sg-library-body .sg-library-card-meta {
    color: #94a3b8;
}

.sg-library-body .sg-library-card-cover img {
    object-position: center top;
}

.sg-library-body .sg-library-card-cover {
    background: rgba(0, 0, 0, 0.2);
}

.sg-library-body .sg-library-card--list:hover,
.sg-library-body .sg-library-card--list:focus {
    transform: translateY(-2px);
}

/* 分页 */
.sg-library-body .sg-page-btn {
    color: #cbd5e1;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.sg-library-body .sg-page-btn:hover:not([disabled]) {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.18);
    border-color: rgba(147, 197, 253, 0.35);
}

.sg-library-body .sg-page-btn.active {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border-color: transparent;
}

/* 空状态 / 加载 */
.sg-library-empty,
.sg-library-loading {
    text-align: center;
    padding: 4rem 1.5rem;
}

.sg-library-empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.55;
}

.sg-library-empty-title {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #f8fafc;
}

.sg-library-empty-desc {
    margin: 0;
    font-size: 1.125rem;
    color: #94a3b8;
}

.sg-library-loading-spinner {
    display: inline-block;
    width: 2.5rem;
    height: 2.5rem;
    border: 4px solid rgba(96, 165, 250, 0.25);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: sg-library-spin 0.9s linear infinite;
}

@keyframes sg-library-spin {
    to { transform: rotate(360deg); }
}

.sg-library-loading-text {
    margin: 1rem 0 0;
    font-size: 1.125rem;
    color: #94a3b8;
}
