/* ========== 全站 H5 移动端适配 ========== */

:root {
    --h5-tabbar-h: 56px;
}

html.site-h5-root {
    overflow-x: hidden;
    overflow-y: auto;
}

body.site-h5 {
    overflow: visible;
    -webkit-tap-highlight-color: transparent;
    -webkit-overflow-scrolling: touch;
}

.site-h5 .portal-shell {
    min-height: 100dvh;
    min-height: -webkit-fill-available;
}

.site-h5 .portal-main-site {
    flex: 1;
    min-width: 0;
}

/* ---------- 底部导航栏 ---------- */
.site-tabbar {
    display: none;
}

.site-search-sheet {
    display: none;
}

/* ---------- 移动端顶栏菜单 ---------- */
.news-site-nav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--portal-line);
    background: var(--portal-surface);
    color: var(--portal-text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
}

.site-nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 280;
    background: rgba(7, 16, 24, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.site-nav-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

body.site-nav-open {
    overflow: hidden;
    touch-action: none;
}

/* ---------- 通用触控优化 ---------- */
@media (max-width: 768px) {
    .news-site-nav-toggle {
        display: inline-flex;
    }

    .news-site-header-inner {
        flex-wrap: nowrap;
        gap: 10px;
        padding: 10px clamp(12px, 3vw, 16px);
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
    }

    .news-site-brand {
        flex: 1;
        min-width: 0;
    }

    .news-site-brand-text {
        max-width: 9.5em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .news-site-nav-toggle {
        margin-left: auto;
    }

    .news-site-header-actions {
        flex-shrink: 0;
    }

    .news-site-nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 290;
        order: unset;
        width: min(320px, 88vw);
        max-width: 88vw;
        flex: none;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        overflow-x: hidden;
        overflow-y: auto;
        padding: calc(18px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
        background: var(--portal-surface);
        border-left: 1px solid var(--portal-line);
        box-shadow: -12px 0 40px rgba(7, 16, 24, 0.18);
        transform: translateX(105%);
        transition: transform 0.32s var(--portal-ease, ease);
        -webkit-overflow-scrolling: touch;
    }

    .news-site-nav.is-open {
        transform: translateX(0);
    }

    .news-site-nav-link {
        width: 100%;
        text-align: left;
        padding: 12px 14px;
        font-size: 15px;
        border-radius: 12px;
    }

    .news-site-nav-divider {
        width: 100%;
        height: 1px;
        margin: 8px 0;
    }

    .site-page-shell,
    .home-fullscreen .home-body-inner,
    .news-detail-page.site-page-shell {
        padding-left: clamp(12px, 3.5vw, 16px);
        padding-right: clamp(12px, 3.5vw, 16px);
    }

    .site-footer-inner {
        padding-left: clamp(12px, 3.5vw, 16px);
        padding-right: clamp(12px, 3.5vw, 16px);
    }

    .site-footer-grid {
        grid-template-columns: 1fr;
        gap: 24px;
        text-align: center;
    }

    .site-footer-brand,
    .site-footer-bottom {
        text-align: center;
    }

    .site-footer-logo {
        justify-content: center;
    }

    .site-footer-desc {
        margin-left: auto;
        margin-right: auto;
    }

    .site-footer-stats {
        justify-content: center;
    }

    .site-footer-links-grid {
        grid-template-columns: 1fr;
    }

    .site-footer-buy-btn {
        width: 100%;
        max-width: 280px;
    }

    /* 首页 */
    .home-fullscreen .home-hero-full {
        padding: 28px 12px 24px;
    }

    .home-fullscreen .home-hero-stats {
        grid-template-columns: 1fr;
    }

    .home-fullscreen .home-hero-stat {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
        padding: 14px 16px;
    }

    .home-fullscreen .home-hero-stat span {
        margin-top: 0;
    }

    .home-adaptive .home-tool-grid {
        grid-template-columns: 1fr;
    }

    /* 工具页 */
    .tool-adaptive .portal-tool-header {
        flex-direction: row;
        align-items: flex-start;
    }

    .tool-adaptive .tool-actions {
        flex-direction: column;
    }

    .tool-adaptive .tool-actions .btn {
        width: 100%;
    }

    .tool-adaptive .form-textarea {
        min-height: 200px;
    }

    /* 新闻 */
    .news-adaptive .news-main-head {
        padding: 16px;
    }

    .news-adaptive .news-list-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .news-adaptive .news-article {
        padding: 20px 16px 24px;
    }

    .news-adaptive .news-article-title {
        font-size: 22px;
    }

    .news-adaptive .news-detail-nav {
        grid-template-columns: 1fr;
    }

    .news-adaptive .news-detail-nav-item.is-empty {
        display: none;
    }

    .news-adaptive .news-detail-nav-item.is-next {
        text-align: left;
    }

    /* 赞助 */
    .sponsor-detail-page .portal-hero {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px 16px;
    }

    .sponsor-detail-page .portal-hero-stats {
        width: 100%;
    }

    .sponsor-detail-page .sponsor-layout {
        grid-template-columns: 1fr;
    }

    .sponsor-detail-page .sponsor-roll {
        height: 320px;
    }

    /* 底部留白（给 TabBar） */
    .site-h5 .portal-content,
    .site-h5 .site-page-shell,
    .site-h5 .home-fullscreen .home-body-inner {
        padding-bottom: calc(20px + var(--h5-tabbar-h) + env(safe-area-inset-bottom, 0px));
    }

    .site-h5 .site-footer {
        padding-bottom: calc(28px + var(--h5-tabbar-h) + env(safe-area-inset-bottom, 0px));
    }

    /* 底部 TabBar */
    .site-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 260;
        height: calc(var(--h5-tabbar-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(255, 255, 255, 0.96);
        border-top: 1px solid var(--portal-line, var(--border));
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: 0 -4px 24px rgba(7, 16, 24, 0.06);
    }

    html[data-theme="dark"] .site-tabbar {
        background: rgba(10, 18, 17, 0.96);
    }

    .site-tabbar-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 0;
        padding: 6px 4px;
        border: none;
        background: transparent;
        color: var(--portal-text-2, var(--color-text-secondary));
        text-decoration: none;
        font-size: 11px;
        line-height: 1.2;
        cursor: pointer;
        -webkit-appearance: none;
        appearance: none;
    }

    .site-tabbar-icon {
        font-size: 20px;
        line-height: 1;
    }

    .site-tabbar-label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .site-tabbar-item.is-active {
        color: var(--portal-primary, var(--color-primary));
        font-weight: 600;
    }

    /* 移动端搜索面板 */
    .site-search-sheet {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 300;
        pointer-events: none;
        visibility: hidden;
        transition: visibility 0.28s ease;
    }

    .site-search-sheet.is-open {
        pointer-events: auto;
        visibility: visible;
    }

    .site-search-sheet-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(7, 16, 24, 0.45);
        opacity: 0;
        transition: opacity 0.28s ease;
    }

    .site-search-sheet.is-open .site-search-sheet-backdrop {
        opacity: 1;
    }

    .site-search-sheet-panel {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
        background: var(--portal-surface, var(--bg-card));
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 32px rgba(7, 16, 24, 0.12);
        transform: translateY(105%);
        transition: transform 0.32s var(--portal-ease, ease);
    }

    .site-search-sheet.is-open .site-search-sheet-panel {
        transform: translateY(0);
    }

    .site-search-sheet-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
        font-size: 16px;
        font-weight: 600;
    }

    .site-search-sheet-close {
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 10px;
        background: var(--portal-primary-soft, rgba(26, 155, 138, 0.1));
        color: var(--portal-text, inherit);
        font-size: 16px;
        cursor: pointer;
    }

    .site-search-sheet-body {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .site-search-sheet-body .form-control {
        width: 100%;
        padding: 12px 14px;
        font-size: 16px;
        border-radius: 12px;
    }

    .site-search-sheet-submit {
        width: 100%;
        padding: 12px 16px;
        border-radius: 12px;
    }

    body.site-search-open {
        overflow: hidden;
        touch-action: none;
    }

    /* 工具页表单与结果 */
    .tool-adaptive .form-row {
        flex-direction: column;
    }

    .tool-adaptive .form-row .form-group {
        min-width: 0;
        width: 100%;
    }

    .tool-adaptive .radio-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .tool-adaptive .result-box {
        max-height: min(60vh, 420px);
        font-size: 12px;
        padding: 14px;
        -webkit-overflow-scrolling: touch;
    }

    .tool-adaptive .result-box .ref-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tool-adaptive .result-box .ref-table th,
    .tool-adaptive .result-box .ref-table td {
        white-space: nowrap;
        font-size: 12px;
        padding: 8px 10px;
    }

    .tool-adaptive .diff-summary {
        font-size: 13px;
        padding: 10px 12px;
        border-radius: 10px;
        background: var(--portal-primary-soft, rgba(26, 155, 138, 0.08));
        margin-bottom: 10px;
        word-break: break-word;
    }

    .tool-adaptive .news-breadcrumb {
        font-size: 13px;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .tool-adaptive .news-breadcrumb::-webkit-scrollbar {
        display: none;
    }

    .tool-adaptive .portal-tool-header-title {
        font-size: clamp(20px, 5.5vw, 26px);
    }

    /* 新闻列表 */
    .news-adaptive .news-breadcrumb {
        overflow-x: auto;
        white-space: nowrap;
    }

    /* 返回顶部 */
    .portal-body .back-top {
        right: calc(12px + env(safe-area-inset-right, 0px));
        bottom: calc(16px + var(--h5-tabbar-h) + env(safe-area-inset-bottom, 0px));
        width: 44px;
        height: 44px;
    }

    /* 960px 以下隐藏顶栏横向分类，改用手势抽屉 */
    .news-site-nav {
        order: unset !important;
        width: auto !important;
    }
}

@media (max-width: 480px) {
    .news-list-link {
        padding: 14px 0;
    }

    .news-list-cover {
        height: 160px;
    }

    .portal-tool-card {
        padding: 14px 40px 14px 14px;
    }

    .sponsor-amounts,
    .sponsor-pay-tabs {
        gap: 8px;
    }

    .sponsor-amount-btn,
    .sponsor-pay-tab {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
        text-align: center;
    }
}

@media (hover: none) and (pointer: coarse) {
    .site-h5 .news-site-nav-link:active,
    .site-h5 .news-site-action:active,
    .site-h5 .portal-tool-card:active,
    .site-h5 .news-list-link:active,
    .site-h5 .news-grid-card:active,
    .site-h5 .news-col-featured:active,
    .site-h5 .news-col-link:active,
    .site-h5 .site-footer-buy-btn:active {
        transform: scale(0.98);
    }
}

@media (prefers-reduced-motion: reduce) {
    .news-site-nav,
    .site-nav-overlay {
        transition: none;
    }
}
