.sg-resource-filters {
    padding: 14px 20px 8px;
    border-bottom: 1px solid var(--sg-wf-border);
    color: var(--sg-wf-muted);
    font-size: 12px;
    background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 72%);
}

.sg-resource-filter-head,
.sg-resource-filter-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
}

.sg-resource-filter-primary {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    column-gap: 8px;
    row-gap: 9px;
    margin-bottom: 12px;
    min-width: 0;
}

/* 宽屏时下拉框保持合理间距，不强制两端对齐 */
@media (min-width: 1100px) {
    .sg-resource-filter-primary {
        justify-content: flex-start;
        column-gap: 12px;
    }
}

.sg-resource-filter-select {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0;
    min-width: 0;
}

.sg-resource-filter-caption {
    display: inline-flex;
    height: 32px;
    align-items: center;
    padding: 0 8px;
    border: 1px solid rgba(255, 178, 0, .42);
    border-right: 0;
    border-radius: 7px 0 0 7px;
    background: linear-gradient(180deg, rgba(255, 190, 40, .18), rgba(255, 178, 0, .09));
    color: var(--sg-wf-text);
    font-weight: 600;
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}

.sg-resource-filter-divider {
    flex: 0 0 1px;
    align-self: stretch;
    margin: 2px 0;
    background: var(--sg-wf-border);
}

.sg-resource-filter-select select {
    min-width: 62px;
    height: 32px;
    padding: 0 22px 0 7px;
    border: 1px solid rgba(120, 130, 145, .28);
    border-radius: 0 7px 7px 0;
    outline: 0;
    -webkit-appearance: none;
    appearance: none;
    background-color: rgba(255, 255, 255, .055);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='m1 1 4 4 4-4' fill='none' stroke='%238b929c' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 7px center;
    background-size: 8px 5px;
    color: var(--sg-wf-muted);
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease;
}

.sg-resource-filter-select select:hover,
.sg-resource-filter-select select:focus {
    border-color: rgba(255, 178, 0, .8);
    background-color: rgba(255, 255, 255, .09);
}

.sg-resource-filter-dropdowns {
    align-items: center;
}

.sg-resource-filter-vendor-select select {
    min-width: 62px;
    width: auto;
    max-width: none;
    white-space: nowrap;
}

.sg-resource-filter-vendor-select:last-child select {
    min-width: 62px;
    width: auto;
}

.sg-resource-filter-head {
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    color: var(--sg-wf-text);
}

.sg-resource-filter-head a {
    color: var(--sg-wf-accent);
    text-decoration: none;
}

.sg-resource-filter-head > div {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.sg-resource-filter-toggle {
    display: none;
    width: 32px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--sg-wf-border);
    border-radius: 5px;
    place-items: center;
    background: transparent;
    color: var(--sg-wf-muted);
    cursor: pointer;
}

.sg-resource-filter-toggle span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.sg-resource-filter-row {
    margin-bottom: 8px;
}

.sg-resource-filter-row-category + .sg-resource-filter-row-category:not(.sg-resource-filter-row-category-root) {
    border-top: 1px solid rgba(243, 169, 10, 0.3);
    padding-top: 8px;
}

.sg-resource-filter-row-category > .sg-resource-filter-options {
    display: block;
    margin-left: 0;
}

.sg-resource-filter-line {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    margin-bottom: 4px;
}

.sg-resource-filter-line:last-child {
    margin-bottom: 0;
}

.sg-resource-filter-line.is-justified {
    justify-content: space-between;
}

/* 布局切换按钮：分类行末行最右侧 */
.sg-resource-filter-line.has-view-switch .sg-waterfall-view-switch {
    margin-left: auto;
    align-self: center;
}

.sg-resource-filter-row-category .sg-resource-filter-option {
    padding-right: 6px;
    padding-left: 6px;
}

.sg-resource-filter-row > span {
    flex: 0 0 42px;
    color: var(--sg-wf-text);
    font-weight: 600;
    line-height: 28px;
}

.sg-resource-filter-row-sort > span {
    flex: 0 0 auto;
    min-width: 2em;
    white-space: nowrap;
    writing-mode: horizontal-tb;
}

.sg-resource-filter-options {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.sg-resource-filter-option {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 0 9px;
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--sg-wf-muted);
    line-height: 1;
    text-decoration: none;
    transition: color .2s ease, border-color .2s ease, background-color .2s ease, transform .2s ease;
}

.sg-resource-filter-option:hover,
.sg-resource-filter-option:focus-visible,
.sg-resource-filter-option.is-active {
    border-color: var(--sg-wf-accent);
    background: var(--focus-color-opacity1, rgba(243, 169, 10, .1));
    color: var(--sg-wf-accent);
}

.sg-resource-filter-option:hover {
    transform: translateY(-1px);
}

/* 三级分类单行导航：父分类按钮左侧的层级箭头，独立于按钮之外（位于两按钮间隙）。
   margin-left 为箭头字形预留空间：不换行的分类行 gap 仅 2px，无此边距箭头会叠到前一按钮上 */
.sg-resource-filter-option.sg-resource-option-parent {
    position: relative;
    margin-left: 11px;
}

.sg-resource-filter-option.sg-resource-option-parent::before {
    content: '\203A';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 3px;
    color: var(--sg-wf-muted, #7b8190);
    font-weight: 700;
    line-height: 1;
}

/* 三级分类单行导航：跳转按钮（全部分类/父分类）与同级分类分组之间的分割线。
   独立 flex 子项：在 space-between 分行布局下两侧空间自动均分，始终处于正中 */
.sg-resource-filter-divider-item {
    flex: 0 0 1px;
    align-self: center;
    width: 1px;
    height: 16px;
    margin: 0;
    background: var(--sg-wf-muted, #7b8190);
    opacity: .55;
}

.sg-resource-filter-row-sort {
    align-items: center;
    margin-top: 12px;
    margin-bottom: 0;
    padding: 10px 0 2px;
    border-top: 1px solid var(--sg-wf-border);
}

.sg-resource-filter-row-sort > span {
    display: inline-flex;
    height: 22px;
    align-items: center;
    padding-right: 14px;
    border-right: 1px solid var(--sg-wf-border);
    margin-right: 2px;
    color: var(--sg-wf-text);
    font-weight: 700;
}

.sg-resource-filter-row-sort .sg-resource-filter-options {
    align-items: center;
    gap: 4px;
}

.sg-resource-filter-row-sort .sg-resource-filter-option {
    min-height: 24px;
    padding: 0 8px;
    font-size: 12px;
    border-radius: 4px;
}

.sg-resource-filter-row-sort .sg-resource-filter-option.is-active {
    background: var(--focus-color-opacity1, rgba(243, 169, 10, .12));
}

@media (max-width: 767px) {
    .sg-resource-filter-row-sort .sg-resource-filter-options {
        flex-wrap: nowrap;
    }

    .sg-resource-filter-row-sort .sg-resource-filter-option {
        min-height: 22px;
        padding: 0 6px;
        font-size: 11px;
        white-space: nowrap;
    }

    .sg-resource-filter-row-sort > span {
        height: 20px;
        padding-right: 8px;
        margin-right: 2px;
        font-size: 12px;
    }
}

.sg-resource-filter-row-sort .sg-resource-filter-reset {
    flex: 0 0 auto;
    margin-left: auto;
    padding-left: 14px;
    color: var(--sg-wf-accent);
    font-weight: 600;
    text-decoration: none;
}

.sg-resource-filter-row-sort .sg-resource-filter-reset:hover,
.sg-resource-filter-row-sort .sg-resource-filter-reset:focus-visible {
    color: var(--sg-wf-text);
}

.sg-resource-filter-row-sort .fa {
    margin-right: 5px;
    font-size: 11px;
}

.sg-resource-selected {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-top: 4px;
    padding: 10px 0 6px;
    border-top: 1px solid var(--sg-wf-border);
}

.sg-resource-selected > strong {
    flex: 0 0 42px;
    color: var(--sg-wf-text);
    line-height: 26px;
}

.sg-resource-selected > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sg-resource-selected a {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    border: 1px solid var(--sg-wf-border);
    border-radius: 5px;
    color: var(--sg-wf-text);
    text-decoration: none;
}

.sg-resource-selected a:hover,
.sg-resource-selected a:focus-visible {
    border-color: var(--sg-wf-accent);
    color: var(--sg-wf-accent);
}

/* 文章数量统计：已选行最右侧（无已选项时整行连同计数一起不渲染） */
.sg-resource-selected > .sg-waterfall-count {
    flex: 0 0 auto;
    align-self: center;
    margin-left: auto;
    line-height: 26px;
}

.sg-resource-empty {
    display: grid;
    min-height: 240px;
    grid-column: 1 / -1;
    place-content: center;
    justify-items: center;
    gap: 10px;
    color: var(--sg-wf-muted);
}

.sg-resource-empty i {
    font-size: 30px;
}

.sg-resource-classic-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sg-resource-classic-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--sg-wf-border);
    border-radius: 8px;
    background: var(--sg-wf-surface);
    box-shadow: 0 5px 18px rgba(30, 38, 60, .05);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.sg-resource-classic-card:hover {
    border-color: #f3a90a;
    box-shadow: 0 12px 28px rgba(30, 38, 60, .13);
    transform: translateY(-3px);
}

.sg-resource-classic-image {
    position: relative;
    display: flex;
    width: 100%;
    aspect-ratio: 1 / 1;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: transparent;
}

.sg-resource-classic-image img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sg-resource-classic-placeholder {
    color: var(--sg-wf-muted);
    font-size: 28px;
}

.sg-resource-classic-body {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    padding: 12px 14px 10px;
}

.sg-resource-classic-body h2 {
    min-height: 43.5px;
    margin: 0 0 9px;
    font-size: 15px;
    line-height: 1.45;
}

.sg-resource-classic-body h2 a {
    display: -webkit-box;
    overflow: hidden;
    color: var(--sg-wf-text);
    text-decoration: none;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.sg-resource-classic-body h2 a:hover {
    color: var(--sg-wf-accent);
}

.sg-resource-classic-taxonomy {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin-bottom: 9px;
    overflow: hidden;
}

.sg-resource-classic-taxonomy a {
    display: inline-flex;
    min-width: 0;
    flex: 0 1 auto;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 12px;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
}

.sg-resource-classic-taxonomy a:hover {
    filter: brightness(.94);
}

.sg-resource-classic-taxonomy a span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sg-resource-classic-taxonomy a i {
    flex: 0 0 auto;
    font-size: 12px;
}

.sg-resource-classic-taxonomy-category {
    background: rgba(42, 153, 224, .12);
    color: #1685d1;
}

.sg-resource-classic-taxonomy-topic {
    background: rgba(247, 116, 44, .12);
    color: #e8611a;
}

.sg-resource-classic-taxonomy-tag {
    background: rgba(104, 112, 124, .12);
    color: #68707c;
}

.sg-resource-classic-meta,
.sg-resource-classic-meta-left,
.sg-resource-classic-stats {
    display: flex;
    align-items: center;
    min-width: 0;
    color: var(--sg-wf-muted);
    font-size: 11px;
}

.sg-resource-classic-meta {
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 9px;
}

.sg-resource-classic-meta-left {
    flex: 1 1 auto;
    gap: 7px;
    overflow: hidden;
}

.sg-resource-classic-author {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

.sg-resource-classic-author img {
    width: 28px;
    height: 28px;
    display: block;
    border-radius: 50%;
    object-fit: cover;
}

.sg-resource-classic-meta time {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sg-resource-classic-stats {
    flex: 0 0 auto;
    gap: 9px;
    white-space: nowrap;
}

.sg-resource-classic-stats span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sg-resource-classic-stats i {
    width: 12px;
    text-align: center;
}

.dark-theme .sg-resource-classic-taxonomy-category,
.is-dark .sg-resource-classic-taxonomy-category,
html[data-theme="dark"] .sg-resource-classic-taxonomy-category,
body.dark-mode .sg-resource-classic-taxonomy-category {
    color: #54b7f4;
}

.dark-theme .sg-resource-classic-taxonomy-topic,
.is-dark .sg-resource-classic-taxonomy-topic,
html[data-theme="dark"] .sg-resource-classic-taxonomy-topic,
body.dark-mode .sg-resource-classic-taxonomy-topic {
    color: #ff9a61;
}

.dark-theme .sg-resource-classic-taxonomy-tag,
.is-dark .sg-resource-classic-taxonomy-tag,
html[data-theme="dark"] .sg-resource-classic-taxonomy-tag,
body.dark-mode .sg-resource-classic-taxonomy-tag {
    color: #b2bac5;
}

.dark-theme .sg-resource-classic-card,
.is-dark .sg-resource-classic-card,
html[data-theme="dark"] .sg-resource-classic-card,
body.dark-mode .sg-resource-classic-card {
    box-shadow: 0 5px 18px rgba(0, 0, 0, .16);
}

@media (max-width: 899px) {
    .sg-resource-classic-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 599px) {
    .sg-resource-mode .sg-waterfall-view-switch {
        display: inline-flex;
    }

    .sg-resource-filters {
        padding-right: 14px;
        padding-left: 14px;
    }

    .sg-resource-filter-row {
        gap: 9px;
    }

    .sg-resource-filter-primary {
        justify-content: space-between;
        gap: 6px;
    }

    /* 移动端下拉框整体缩小：降低高度/内边距/字号，减少换行排数 */
    .sg-resource-filter-caption {
        height: 28px;
        padding: 0 6px;
        font-size: 11px;
    }

    .sg-resource-filter-select select {
        height: 28px;
        min-width: 46px;
        padding: 0 17px 0 6px;
        font-size: 11px;
    }

    .sg-resource-filter-vendor-select select {
        min-width: 46px;
    }

    .sg-resource-filter-select {
        flex: 0 0 auto;
        min-width: 0;
    }

    .sg-resource-filter-divider {
        display: none;
    }

    .sg-resource-filter-vendor-select {
        flex: 0 0 auto;
    }

    .sg-resource-filter-vendor-select select {
        width: auto;
        min-width: 62px;
        max-width: none;
    }

    .sg-resource-filter-vendor-select:last-child select {
        width: auto;
        min-width: 62px;
    }

    .sg-resource-filter-select select {
        min-width: 62px;
        width: auto;
    }

    .sg-resource-filter-toggle {
        display: inline-grid;
    }

    .sg-resource-filter-body {
        display: block;
    }

    .sg-resource-filter-row-category > .sg-resource-filter-options {
        margin-left: 0;
        justify-content: flex-start;
    }

    .sg-resource-filter-row > span {
        flex-basis: 36px;
    }

    .sg-resource-selected {
        gap: 8px;
    }

    .sg-resource-selected > strong {
        flex-basis: 36px;
    }

    .sg-resource-classic-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .sg-resource-classic-taxonomy {
        gap: 5px;
    }

    .sg-resource-classic-taxonomy a {
        padding: 5px 7px;
        font-size: 11px;
    }

    .sg-resource-classic-meta {
        gap: 6px;
    }

    .sg-resource-classic-stats {
        gap: 8px;
    }
}

@media (max-width: 520px) {
    .sg-resource-filter-primary {
        justify-content: flex-start;
    }
}

@supports (container-type: inline-size) {
    @container (max-width: 599px) {
        .sg-resource-classic-grid {
            grid-template-columns: minmax(0, 1fr);
        }
    }

    @container (min-width: 600px) and (max-width: 899px) {
        .sg-resource-classic-grid {
            grid-template-columns: repeat(2, minmax(0, 1fr));
        }
    }

    @container (min-width: 900px) {
        .sg-resource-classic-grid {
            grid-template-columns: repeat(3, minmax(0, 1fr));
        }
    }
}
