:root {
    --h-content-max: 1180px;
    --h-bg: #efece6;
    --h-surface: #fdfcfa;
    --h-text: #1c1917;
    --h-muted: #78716c;
    --h-border: #d6d3cd;
    --h-brand: #c2410c;
    --h-accent: #9a3412;
    --h-accent-soft: rgba(194, 65, 12, 0.18);
    --h-accent-hover: #7c2d12;
    --h-shadow: 0 1px 2px rgba(28, 25, 23, 0.05);
    --h-shadow-lg: 0 12px 40px rgba(28, 25, 23, 0.08);
    --h-radius: 10px;
    --h-official: #1d4ed8;
    --h-official-soft: rgba(29, 78, 216, 0.12);
    --h-official-border: rgba(29, 78, 216, 0.35);
    --logo-box: 48px;
    --h-topbar-bg: var(--h-bg);
    --h-cat-strip-bg: transparent;
    --h-heading-icon: #c2410c;
    --h-tab-pill-bg: transparent;
    --h-tab-pill-text: #57534e;
}

@media (min-width: 1320px) {
    :root {
        --h-content-max: 1280px;
    }
}

@media (min-width: 1560px) {
    :root {
        --h-content-max: 1420px;
    }
}

[data-theme="dark"] {
    --h-bg: #141211;
    --h-surface: #1c1917;
    --h-text: #fafaf9;
    --h-muted: #a8a29e;
    --h-border: #44403c;
    --h-brand: #fb923c;
    --h-accent: #fdba74;
    --h-accent-soft: rgba(251, 146, 60, 0.18);
    --h-accent-hover: #fed7aa;
    --h-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    --h-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
    --h-official: #60a5fa;
    --h-official-soft: rgba(96, 165, 250, 0.14);
    --h-official-border: rgba(96, 165, 250, 0.45);
    --h-topbar-bg: var(--h-bg);
    --h-cat-strip-bg: transparent;
    --h-heading-icon: #fb923c;
    --h-tab-pill-bg: transparent;
    --h-tab-pill-text: #d6d3d1;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

.skip-link {
    position: absolute;
    left: -9999px;
}

.skip-link:focus {
    left: 1rem !important;
    top: 1rem;
    z-index: 100;
    padding: 0.5rem 0.75rem;
    background: var(--h-accent);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
}

/* 卡密门禁：全屏半透明遮罩 + 卡片在视口正中弹出（与详情页是否滚动无关） */
.card-gate {
    position: fixed;
    inset: 0;
    z-index: 200;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    place-content: center;
    padding: max(1.25rem, env(safe-area-inset-top, 0px)) max(1.25rem, env(safe-area-inset-right, 0px))
        max(1.25rem, env(safe-area-inset-bottom, 0px)) max(1.25rem, env(safe-area-inset-left, 0px));
    min-height: 100vh;
    min-height: 100dvh;
    overflow: auto;
    overscroll-behavior: contain;
    background: rgba(28, 25, 23, 0.42);
}

[data-theme="dark"] .card-gate {
    background: rgba(0, 0, 0, 0.55);
}

.card-gate[hidden] {
    display: none !important;
}

@keyframes card-gate-pop {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.card-gate:not([hidden]) .card-gate-panel {
    animation: card-gate-pop 0.22s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .card-gate:not([hidden]) .card-gate-panel {
        animation: none;
    }
}

body.card-gate-open .home-hero-toolbar,
body.card-gate-open .shell > *,
body.card-gate-open .site-foot,
body.card-gate-open #fab-top,
body.card-gate-open .detail-main {
    pointer-events: none;
    user-select: none;
}

.card-gate-panel {
    position: relative;
    flex: 0 1 auto;
    align-self: center;
    width: min(100%, 340px);
    margin: auto;
    padding: 1.1rem 1.05rem 1rem;
    border-radius: 8px;
    background: var(--h-surface);
    border: 1px solid var(--h-border);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
    max-height: min(88vh, 560px);
    max-height: min(88dvh, 560px);
    overflow-y: auto;
}

[data-theme="dark"] .card-gate-panel {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.card-gate-title {
    margin: 0 0 0.85rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--h-border);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--h-text);
}

.card-gate-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--h-muted);
    margin: 0 0 0.35rem;
}

.card-gate-input {
    width: 100%;
    height: 42px;
    padding: 0 0.65rem;
    border-radius: 4px;
    border: 1px solid var(--h-border);
    background: var(--h-surface);
    color: var(--h-text);
    font-size: 0.9375rem;
    font-family: ui-monospace, Consolas, monospace;
    letter-spacing: 0.02em;
}

[data-theme="dark"] .card-gate-input {
    background: var(--h-surface);
}

.card-gate-input:focus {
    outline: none;
    border-color: var(--h-accent);
}

.card-gate-msg {
    min-height: 1.25rem;
    margin: 0.5rem 0 0;
    font-size: 0.86rem;
    color: #b91c1c;
}

[data-theme="dark"] .card-gate-msg {
    color: #fca5a5;
}

.card-gate-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

@media (max-width: 320px) {
    .card-gate-actions {
        grid-template-columns: 1fr;
    }
}

.card-gate-cancel.chip-btn,
.card-gate-submit.chip-btn {
    width: 100%;
    min-height: 40px;
    justify-content: center;
    padding: 0.45rem 0.65rem;
    font-size: 0.875rem;
    border-radius: 4px;
    font-weight: 500;
}

.card-gate-cancel.chip-btn {
    background: var(--h-surface);
}

.card-gate-cancel.chip-btn:hover {
    border-color: var(--h-muted);
    color: var(--h-text);
}

.card-gate-submit.chip-btn {
    font-weight: 500;
}

/* 网站详情独立页 site.html */
.detail-back {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--h-muted);
    text-decoration: none;
    white-space: nowrap;
}

.detail-back:hover {
    color: var(--h-accent);
}

.detail-main {
    width: 100%;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
    padding: 1rem max(0.75rem, env(safe-area-inset-left, 0px)) 2.75rem max(0.75rem, env(safe-area-inset-right, 0px));
}

/* App / web-view 内嵌时底部常有原生 Tab，为主内容预留空间（亦可显式加 ?embed=1） */
.detail-page.detail-embed .detail-main {
    padding-bottom: calc(2.75rem + 52px + env(safe-area-inset-bottom, 0px));
}

.detail-loading {
    margin: 0;
    text-align: center;
    color: var(--h-muted);
    font-size: 0.95rem;
    padding: 2rem 1rem;
}

.detail-card {
    padding: 1.45rem 1.35rem 1.35rem;
    border-radius: calc(var(--h-radius) + 4px);
    background: var(--h-surface);
    border: 1px solid var(--h-border);
    box-shadow: var(--h-shadow);
}

[data-theme="dark"] .detail-card {
    box-shadow: var(--h-shadow-lg);
}

.detail-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    margin: 0 0 1rem;
}

.detail-kicker {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--h-muted);
}

.detail-back--inline {
    font-size: 0.82rem;
    white-space: normal;
}

/* 详情页头部：默认居中；左栏内由 .detail-hero--ref 改为横向目录站样式 */
.detail-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 0 0 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--h-border);
}

.detail-split-main .detail-hero--ref {
    flex-direction: row;
    align-items: flex-start;
    text-align: left;
    gap: 1rem 1.15rem;
}

.detail-split-main .detail-hero--ref .detail-hero-main {
    flex: 1;
    min-width: 0;
}

.detail-split-main .detail-hero--ref .detail-logo {
    flex-shrink: 0;
    margin-top: 0.15rem;
}

@media (max-width: 520px) {
    .detail-split-main .detail-hero--ref {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .detail-split-main .detail-hero--ref .detail-head-row {
        justify-content: center;
    }

    .detail-split-main .detail-hero--ref .detail-head-badges {
        justify-content: center;
    }
}

.detail-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.28rem 0.45rem;
    margin: 0 0 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--h-border);
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--h-muted);
}

.detail-breadcrumb a {
    color: var(--h-accent);
    font-weight: 600;
    text-decoration: none;
}

.detail-breadcrumb a:hover {
    text-decoration: underline;
}

.detail-bc-sep {
    opacity: 0.45;
    user-select: none;
}

.detail-bc-muted {
    color: var(--h-muted);
}

.detail-bc-current {
    color: var(--h-text);
    font-weight: 700;
}

.detail-meta-row {
    margin: 0.35rem 0 0;
    font-size: 0.82rem;
    color: var(--h-muted);
    line-height: 1.45;
}

.detail-main-actions {
    margin-top: 1.15rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 0.75rem;
}

.detail-btn-verify {
    padding: 0.52rem 1.25rem;
    font-size: 0.93rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--h-brand) 42%, var(--h-border));
    background: color-mix(in srgb, var(--h-brand) 12%, var(--h-bg));
    color: var(--h-accent);
    font-family: inherit;
}

.detail-btn-verify:hover {
    filter: brightness(1.03);
    border-color: color-mix(in srgb, var(--h-brand) 55%, var(--h-border));
}

[data-theme="dark"] .detail-btn-verify {
    background: color-mix(in srgb, var(--h-brand) 18%, var(--h-surface));
}

.detail-btn-verify[hidden] {
    display: none !important;
}

.detail-main-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 1.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 999px;
    text-decoration: none;
}

.detail-main-cta-arrow {
    font-size: 1.15rem;
    font-weight: 400;
    line-height: 1;
    opacity: 0.95;
}

.detail-hero-main {
    width: 100%;
    min-width: 0;
}

.detail-logo {
    display: block;
    width: 80px;
    height: 80px;
    margin: 0;
    padding: 0.4rem;
    box-sizing: border-box;
    border-radius: 18px;
    object-fit: contain;
    object-position: center;
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--h-border) 82%, #94a3b8);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 2px 10px rgba(15, 23, 42, 0.05);
}

[data-theme="dark"] .detail-logo {
    background: #f1f5f9;
    border-color: color-mix(in srgb, var(--h-border) 65%, #64748b);
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.detail-logo--custom {
    padding: 0;
    object-fit: cover;
    object-position: center;
}

.detail-head-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem 0.85rem;
    margin: 0;
}

.detail-head-badges {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    flex-shrink: 0;
    max-width: 44%;
}

.detail-name {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-size: 1.28rem;
    font-weight: 700;
    line-height: 1.32;
    letter-spacing: -0.02em;
    color: var(--h-text);
    word-break: break-word;
}

.detail-official-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    flex-shrink: 0;
    padding: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--h-official);
    background: transparent;
    border: none;
    white-space: nowrap;
}

.detail-card-badge {
    display: inline-block;
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.12rem 0.48rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--h-brand) 14%, var(--h-bg));
    color: var(--h-accent);
    border: 1px solid color-mix(in srgb, var(--h-brand) 32%, var(--h-border));
}

.detail-card-badge[hidden] {
    display: none !important;
}

.detail-cat {
    margin: 0 0 0.75rem;
    font-size: 0.84rem;
    color: var(--h-muted);
    line-height: 1.45;
}

.detail-desc {
    margin: 0 0 1rem;
    font-size: 0.93rem;
    line-height: 1.65;
    color: var(--h-muted);
    text-align: justify;
    text-justify: inter-ideograph;
    hyphens: auto;
    /* 与后台 textarea 一致：保留换行分段 */
    white-space: pre-line;
}

/* 详情页正文区 */
.detail-card.detail-split {
    padding: 1.1rem 1rem 1.25rem;
}

.detail-split-head {
    margin-bottom: 0.85rem;
}

.detail-split-head .detail-card-head {
    margin-bottom: 0;
}

.detail-split-body {
    display: block;
}

@media (max-width: 420px) {
    .detail-head-row {
        flex-direction: column;
        align-items: stretch;
    }

    .detail-head-badges {
        max-width: none;
        justify-content: flex-start;
    }

    .detail-name {
        font-size: 1.15rem;
    }
}

body.home-page {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background-color: var(--h-bg);
    background-image: linear-gradient(180deg, var(--h-surface) 0%, var(--h-bg) 28vh);
    color: var(--h-text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* 宽屏两侧留白：极淡色块 + 细网格，避免「大块死空」 */
@media (min-width: 900px) {
    body.home-page:not(.detail-page) {
        background-image:
            linear-gradient(180deg, var(--h-surface) 0%, var(--h-bg) 28vh),
            radial-gradient(ellipse 48% 70% at 0% 45%, color-mix(in srgb, var(--h-brand) 11%, transparent), transparent 52%),
            radial-gradient(ellipse 48% 70% at 100% 50%, color-mix(in srgb, var(--h-brand) 8%, transparent), transparent 52%);
    }

    [data-theme="dark"] body.home-page:not(.detail-page) {
        background-image:
            linear-gradient(180deg, #1c1917 0%, var(--h-bg) 32vh),
            radial-gradient(ellipse 46% 68% at 0% 42%, rgba(251, 146, 60, 0.07), transparent 52%),
            radial-gradient(ellipse 46% 68% at 100% 52%, rgba(251, 146, 60, 0.055), transparent 52%);
    }
}

@media (max-width: 899px) {
    [data-theme="dark"] body.home-page {
        background-image: linear-gradient(180deg, #1c1917 0%, var(--h-bg) 32vh);
    }
}

.brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
}

/* Logo：1:1 正方形，横版图用 cover 裁剪；居中取景 */
.brand-logo {
    display: block;
    flex-shrink: 0;
    width: var(--logo-box);
    height: var(--logo-box);
    object-fit: cover;
    object-position: center center;
    border-radius: 8px;
    border: 1px solid var(--h-border);
    background: var(--h-surface);
}

.search-wrap {
    min-width: 0;
    position: relative;
}

.search-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--h-muted);
    pointer-events: none;
}

#q {
    width: 100%;
    height: 36px;
    padding: 0 2.35rem 0 2.05rem;
    border: 1px solid var(--h-border);
    border-radius: var(--h-radius);
    background: var(--h-surface);
    color: var(--h-text);
    font-size: 0.86rem;
    outline: none;
    box-shadow: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#q::placeholder {
    color: var(--h-muted);
}

#q:focus {
    border-color: var(--h-brand);
    box-shadow: 0 0 0 3px var(--h-accent-soft);
}

.search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    border: 1px solid var(--h-border);
    color: var(--h-muted);
    background: color-mix(in srgb, var(--h-bg) 70%, var(--h-surface));
    pointer-events: none;
}

@media (max-width: 640px) {
    .search-kbd {
        display: none;
    }
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: calc(var(--h-radius) - 2px);
    border: 1px solid var(--h-border);
    background: var(--h-surface);
    color: var(--h-text);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.icon-btn:hover {
    border-color: var(--h-brand);
    color: var(--h-brand);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

/* 主区域 */
.shell {
    max-width: var(--h-content-max);
    margin: 0 auto;
    padding: 1.1rem 1.15rem 4rem;
}

.home-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    text-align: center;
    margin: 0 0 1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--h-border);
}

.home-hero-kicker {
    width: 100%;
    margin: 0 0 0.65rem;
    text-align: center;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--h-muted);
}

/* Logo 与主标题同一行：整组在版心内水平居中 */
.home-hero-head {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.65rem 0.85rem;
    margin: 0 auto 0.4rem;
    width: 100%;
    max-width: 100%;
}

.home-hero-brand {
    display: block;
    margin: 0;
    flex-shrink: 0;
    line-height: 0;
    text-decoration: none;
    border-radius: 10px;
    transition: transform 0.2s ease;
}

.home-hero-brand:hover {
    transform: translateY(-2px);
}

.home-hero-brand:focus-visible {
    outline: 2px solid var(--h-brand);
    outline-offset: 4px;
}

/* 方形视口内完整显示 Logo（含图内文字），居中、不裁切正文 */
.home-hero-logo-crop {
    display: block;
    width: var(--hero-logo-size, 64px);
    height: var(--hero-logo-size, 64px);
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid var(--h-border);
    background: var(--h-surface);
    box-shadow: var(--h-shadow);
}

.home-hero-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
}

.home-hero-title {
    margin: 0;
    flex: 0 1 auto;
    min-width: 0;
    font-family: ui-serif, Georgia, "Palatino Linotype", "Songti SC", "Noto Serif SC", serif;
    font-size: clamp(1.45rem, 3.8vw, 1.85rem);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: var(--h-text);
    text-align: center;
}

.home-hero-lead {
    margin: 0 auto;
    font-size: 0.86rem;
    color: var(--h-muted);
    max-width: 34rem;
    line-height: 1.55;
}

/* 搜索与主题（原顶部栏，现并入首屏 Hero） */
.home-hero-toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.55rem 0.65rem;
    width: 100%;
    max-width: min(520px, 100%);
    margin: 0.85rem auto 0;
    padding: 0 0.15rem;
}

.home-hero-toolbar .search-wrap {
    flex: 1 1 220px;
    min-width: 0;
    max-width: 100%;
}

.home-hero-toolbar .top-actions {
    flex-shrink: 0;
}

@media (max-width: 380px) {
    .home-hero-head {
        flex-direction: column;
    }
}

.stats-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    margin-bottom: 1.1rem;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.stats-row p {
    margin: 0;
    font-size: 0.84rem;
    color: var(--h-muted);
}

.stats-row strong {
    color: var(--h-text);
    font-weight: 600;
}

.filter-note {
    font-size: 0.78rem;
    color: var(--h-muted);
    padding: 0;
    border-radius: 0;
    background: transparent;
    border-left: 3px solid var(--h-brand);
    padding-left: 0.55rem;
}

.filter-note[hidden] {
    display: none !important;
}

/* 前台：按分类分组 */
.link-board {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

.link-cat-section {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.link-cat-section--muted {
    opacity: 0.92;
}

.link-cat-title-block {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    max-width: 100%;
}

.link-cat-heading-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--h-heading-icon);
}

.link-cat-heading-icon svg {
    display: block;
}

.link-cat-heading {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--h-text);
}

.link-cat-title-block .link-cat-heading {
    padding: 0;
    border: none;
}

/* 一级标题与子分类同一行；浅色边框容器仅从子分类标签区域开始 */
.link-cat-heading-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 1rem;
    margin: 0 0 1rem;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.link-cat-heading-row .link-cat-heading {
    flex-shrink: 0;
}

.link-cat-heading-row .link-sub-tablist {
    margin: 0;
    flex: 0 1 auto;
    max-width: 100%;
    justify-content: flex-start;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    gap: 0.15rem 0.35rem;
}

@media (max-width: 520px) {
    .link-cat-heading-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* 一级下的子分类：下划线式 Tab */
.link-sub-tablist {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.15rem 0.35rem;
}

.link-sub-tab {
    appearance: none;
    margin: 0;
    padding: 0.35rem 0.55rem 0.45rem;
    border-radius: 0;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--h-tab-pill-text);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.link-sub-tab:hover {
    color: var(--h-text);
    border-bottom-color: color-mix(in srgb, var(--h-border) 75%, var(--h-muted));
}

.link-sub-tab[aria-selected="true"] {
    color: var(--h-brand);
    border-bottom-color: var(--h-brand);
}

[data-theme="dark"] .link-sub-tab[aria-selected="true"] {
    color: var(--h-accent);
    border-bottom-color: var(--h-brand);
}

.link-sub-tab:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--h-brand) 65%, var(--h-text));
    outline-offset: 2px;
}

.link-sub-panels {
    min-height: 1rem;
}

/* 挂在父分类下、未指定子分类的链接（不再使用「未分子类」标签） */
.link-cat-direct-links {
    margin: 0 0 1rem;
}

.link-cat-section--muted .link-cat-heading-icon {
    color: var(--h-muted);
}

/* 卡片网格：大屏一排最多 4 个 */
.link-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.65rem;
    grid-template-columns: 1fr;
}

@media (min-width: 480px) {
    .link-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 720px) {
    .link-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 960px) {
    .link-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.link-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    cursor: pointer;
    background: var(--h-surface);
    border: 1px solid var(--h-border);
    border-radius: calc(var(--h-radius) + 2px);
    padding: 0.8rem 0.85rem 0.75rem;
    box-shadow: var(--h-shadow);
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.link-card:hover {
    background: color-mix(in srgb, var(--h-surface) 94%, var(--h-brand));
    border-color: color-mix(in srgb, var(--h-brand) 22%, var(--h-border));
    box-shadow: 0 2px 8px rgba(28, 25, 23, 0.06);
}

[data-theme="dark"] .link-card:hover {
    background: color-mix(in srgb, var(--h-surface) 92%, var(--h-brand));
    border-color: color-mix(in srgb, var(--h-brand) 28%, var(--h-border));
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.link-card--protected {
    background: color-mix(in srgb, var(--h-surface) 96%, var(--h-brand));
    border-color: color-mix(in srgb, var(--h-brand) 28%, var(--h-border));
}

/* 左 Logo | 右：标题行（标题 + 右上官方 / 需验证）+ 简介 — 参考白底描边卡 */
.link-card-top {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    align-items: center;
}

.link-card-logo-wrap {
    flex-shrink: 0;
    width: 58px;
    height: 58px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--h-border) 85%, #cbd5e1);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.06),
        0 2px 8px rgba(15, 23, 42, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

[data-theme="dark"] .link-card-logo-wrap {
    background: #f8fafc;
    border-color: color-mix(in srgb, var(--h-border) 60%, #64748b);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

.favicon {
    width: 46px;
    height: 46px;
    max-width: 82%;
    max-height: 82%;
    border-radius: 10px;
    object-fit: contain;
    object-position: center;
    background: transparent;
    border: none;
    flex-shrink: 0;
}

.favicon--custom {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: inherit;
    object-fit: cover;
    object-position: center;
}

.link-card-body {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.link-card-title-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem 0.65rem;
    width: 100%;
    margin: 0 0 0.15rem;
}

.link-card-badges {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    flex-shrink: 0;
    max-width: 48%;
}

.link-card-official-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    flex-shrink: 0;
    padding: 0;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--h-official);
    background: transparent;
    border: none;
    white-space: nowrap;
}

.link-card-official-mark,
.detail-official-mark {
    width: 15px;
    height: 15px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.detail-official-mark {
    width: 18px;
    height: 18px;
}

.link-card-official-text {
    line-height: 1;
}

.link-card-card-badge {
    display: inline-block;
    flex-shrink: 0;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.42rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--h-brand) 14%, var(--h-bg));
    color: var(--h-accent);
    border: 1px solid color-mix(in srgb, var(--h-brand) 32%, var(--h-border));
}

.link-card-title-row .title-link {
    display: block;
    flex: 1;
    min-width: 0;
    margin: 0;
    font-weight: 700;
    font-size: 1.04rem;
    letter-spacing: -0.015em;
    line-height: 1.32;
    color: var(--h-text);
    text-decoration: none;
    word-break: break-word;
}

.link-card:hover .link-card-title-row .title-link {
    color: var(--h-brand);
}

[data-theme="dark"] .link-card:hover .link-card-title-row .title-link {
    color: var(--h-accent);
}

.link-desc {
    margin: 0.2rem 0 0;
    padding: 0;
    font-size: 0.84rem;
    line-height: 1.52;
    color: var(--h-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
    text-align: left;
}

@media (min-width: 480px) {
    .link-card {
        padding: 0.68rem 0.65rem 0.62rem;
    }

    .link-card-top {
        gap: 0.55rem;
    }

    .link-card-logo-wrap {
        width: 50px;
        height: 50px;
        border-radius: 12px;
    }

    .link-card .favicon:not(.favicon--custom) {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .link-card-title-row .title-link {
        font-size: 0.9rem;
    }

    .link-card-badges {
        max-width: 46%;
    }

    .link-card .link-desc {
        font-size: 0.72rem;
        line-height: 1.45;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        margin-top: 0.12rem;
    }

    .link-card-official-badge {
        font-size: 0.68rem;
    }

    .link-card-official-mark {
        width: 13px;
        height: 13px;
    }

    .link-card-card-badge {
        font-size: 0.58rem;
        padding: 0.08rem 0.34rem;
    }
}

.chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.38rem 0.65rem;
    font-size: 0.8rem;
    font-family: inherit;
    border-radius: 999px;
    border: 1px solid var(--h-border);
    background: var(--h-bg);
    color: var(--h-text);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chip-btn:hover {
    border-color: var(--h-accent);
    color: var(--h-accent);
}

.chip-btn.primary {
    background: var(--h-accent);
    border-color: var(--h-accent);
    color: #fff;
}

.chip-btn.primary:hover {
    background: var(--h-accent-hover);
    border-color: var(--h-accent-hover);
    color: #fff;
}

[data-theme="dark"] .chip-btn.primary {
    background: var(--h-brand);
    border-color: color-mix(in srgb, var(--h-brand) 75%, #000);
    color: #141211;
}

[data-theme="dark"] .chip-btn.primary:hover {
    filter: brightness(1.08);
    border-color: var(--h-brand);
}

.chip-btn svg {
    width: 14px;
    height: 14px;
}

.chip-btn.copied {
    border-color: #16a34a;
    color: #16a34a;
    background: color-mix(in srgb, #16a34a 12%, var(--h-bg));
}

/* 空状态 / 错误 */
.state-panel {
    text-align: center;
    padding: 2.75rem 1.5rem;
    border-radius: var(--h-radius);
    border: 1px dashed var(--h-border);
    background: var(--h-surface);
    box-shadow: none;
}

.state-panel .emoji {
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.state-panel h2 {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.state-panel p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--h-muted);
}

/* 空列表（无数据） */
.state-panel--empty {
    padding: 2.5rem 1.75rem 2.65rem;
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
    border-style: solid;
    border-color: var(--h-border);
    background: var(--h-surface);
    box-shadow: none;
}

.state-panel--empty .empty-state-visual {
    color: var(--h-text);
    margin-bottom: 1rem;
}

.state-panel--empty .empty-state-svg {
    width: min(200px, 72vw);
    height: auto;
    display: block;
    margin: 0 auto;
}

.state-panel--empty .empty-svg-shadow {
    fill: currentColor;
    opacity: 0.08;
}

.state-panel--empty .empty-svg-card {
    fill: var(--h-surface);
    stroke: currentColor;
    stroke-opacity: 0.32;
}

.state-panel--empty .empty-svg-line {
    fill: currentColor;
}

.state-panel--empty .empty-svg-line--a {
    opacity: 0.12;
}

.state-panel--empty .empty-svg-line--b,
.state-panel--empty .empty-svg-line--c {
    opacity: 0.08;
}

.state-panel--empty .empty-svg-badge {
    fill: color-mix(in srgb, var(--h-accent) 28%, var(--h-surface));
    stroke: currentColor;
    opacity: 0.55;
}

.state-panel--empty .empty-svg-link-a {
    fill: currentColor;
    opacity: 0.32;
}

.state-panel--empty .empty-svg-link-b {
    fill: currentColor;
    opacity: 0.42;
}

.state-panel.state-panel--empty h2 {
    font-size: clamp(1.15rem, 2.5vw, 1.28rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.state-panel.state-panel--empty > p {
    margin-top: 0.5rem;
    max-width: 34ch;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.65;
    font-size: 0.92rem;
}

/* 回到顶部 */
#fab-top {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 2px solid var(--h-brand);
    background: var(--h-surface);
    color: var(--h-brand);
    cursor: pointer;
    box-shadow: var(--h-shadow);
    display: grid;
    place-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 40;
}

#fab-top.visible {
    opacity: 1;
    pointer-events: auto;
}

#fab-top:hover {
    background: var(--h-brand);
    color: var(--h-surface);
}

[data-theme="dark"] #fab-top {
    background: var(--h-surface);
    color: var(--h-brand);
    border-color: var(--h-brand);
}

[data-theme="dark"] #fab-top:hover {
    background: var(--h-brand);
    color: #141211;
}

#fab-top svg {
    width: 22px;
    height: 22px;
}

/* 底部 */
.site-foot {
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--h-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--h-muted);
    letter-spacing: 0.02em;
}

@media (max-width: 720px) {
    .home-hero-toolbar {
        max-width: 100%;
        margin-top: 0.75rem;
        padding: 0;
    }

    .shell {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .home-hero {
        margin-bottom: 0.85rem;
        padding-bottom: 0.95rem;
        --hero-logo-size: 56px;
    }
}
