/**
 * 手机端：汉堡顶栏 + 首页卡片等（页面背景与电脑端一致，使用 styles.php 渐变，勿覆盖 body）
 * 依赖 header.php 内 .header-lm-burger / .header-lm-mobile-search
 */
@media (max-width: 768px) {
    html {
        -webkit-tap-highlight-color: transparent;
    }

    /* 顶栏外壳贴边 */
    .site-header-lm .header-lm-shell {
        padding-left: 0;
        padding-right: 0;
        padding-top: 0;
    }

    .site-header-lm {
        margin-bottom: 0;
    }

    /* 与桌面一致：白底卡片顶栏，叠在全局渐变上 */
    .site-header-lm .header-lm-card {
        position: relative;
        z-index: 50;
        background: var(--bg-card, #fff);
        border: 1px solid var(--border-color, #e2e6ec);
        border-radius: var(--lm-r, 10px) var(--lm-r, 10px) 0 0;
        border-bottom: none;
        box-shadow: var(--shadow-card, 0 2px 14px rgba(15, 23, 42, 0.05));
    }

    [data-theme="dark"] .site-header-lm .header-lm-card {
        background: var(--bg-card, #1a1a2e);
        border-color: var(--header-border, rgba(255, 255, 255, 0.1));
    }

    /* 顶栏：汉堡 | Logo | 搜索 — 参考图三栏 */
    .site-header-lm .header-lm-burger,
    .site-header-lm .header-lm-mobile-search {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        margin: 0;
        border: 1px solid var(--border-color, #e2e8f0);
        border-radius: 10px;
        background: var(--bg-input, #eef0f4);
        color: var(--text-primary, #334155);
        font-size: 20px;
        line-height: 1;
        cursor: pointer;
        flex-shrink: 0;
    }
    .site-header-lm .header-lm-burger:hover,
    .site-header-lm .header-lm-mobile-search:hover {
        background: var(--bg-hover, #e6e9ef);
    }

    .site-header-lm .header-lm-burger .header-lm-burger-lines {
        display: flex;
        flex-direction: column;
        gap: 5px;
        width: 20px;
    }
    .site-header-lm .header-lm-burger .header-lm-burger-lines span {
        display: block;
        height: 2px;
        background: var(--text-primary, #334155);
        border-radius: 1px;
    }

    .site-header-lm .header-lm-top {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        grid-template-rows: auto auto;
        grid-template-areas:
            "burger brand search"
            "drawer drawer drawer";
        align-items: center;
        gap: 8px 10px;
        padding: 10px 12px 8px;
        min-height: unset !important;
        flex-wrap: unset;
    }

    .site-header-lm .header-lm-burger {
        grid-area: burger;
    }
    .site-header-lm .header-lm-brand {
        grid-area: brand;
        flex: unset;
        width: auto;
        max-width: none;
        justify-self: center;
        text-align: center;
    }
    .site-header-lm .header-lm-mobile-search {
        grid-area: search;
    }
    .site-header-lm .header-lm-actions {
        grid-area: drawer;
        flex: unset;
        width: 100%;
        max-width: none;
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        transition: max-height 0.35s ease, opacity 0.25s ease, margin 0.25s ease;
        margin: 0;
        padding: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    body.header-lm-nav-open .site-header-lm .header-lm-actions {
        max-height: min(70vh, 520px);
        opacity: 1;
        margin-top: 4px;
        padding-bottom: 8px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.header-lm-nav-open .site-header-lm .header-lm-burger .header-lm-burger-lines span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    body.header-lm-nav-open .site-header-lm .header-lm-burger .header-lm-burger-lines span:nth-child(2) {
        opacity: 0;
    }
    body.header-lm-nav-open .site-header-lm .header-lm-burger .header-lm-burger-lines span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
    .site-header-lm .header-lm-burger .header-lm-burger-lines span {
        transition: transform 0.25s ease, opacity 0.2s ease;
    }

    .site-header-lm .header-lm-menu {
        width: 100%;
        border-top: 1px solid var(--border-color, #e2e8f0);
        padding-top: 10px;
    }
    .site-header-lm .header-lm-menu-list {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .site-header-lm .header-lm-menu-link {
        color: var(--text-secondary, #475569) !important;
        border-radius: 8px;
        padding: 10px 12px;
    }
    .site-header-lm .header-lm-menu-link:hover,
    .site-header-lm .header-lm-menu-link.is-active {
        background: color-mix(in srgb, var(--primary, #3088a3) 10%, transparent);
        color: var(--primary, #3088a3) !important;
    }

    .site-header-lm .header-lm-toolbar {
        width: 100%;
        align-self: stretch;
        margin-left: 0;
    }
    .site-header-lm .header-lm-toolbar .header-right {
        width: 100%;
        height: auto !important;
        min-height: 0;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--border-color, #e2e8f0);
    }

    .site-header-lm .header-top-search {
        display: flex !important;
        width: 100%;
        flex: 1 1 100%;
        order: -1;
    }
    .site-header-lm .header-lm-toolbar .header-top-search-box {
        width: 100% !important;
        max-width: none !important;
    }

    /* 以下按钮恢复为与 header.css / 桌面一致的浅色顶栏风格 */
    .site-header-lm .header-login-btn {
        background: #f1f5f9;
        border-color: #e2e8f0;
        color: var(--header-text, #334155) !important;
    }
    .site-header-lm .lang-btn {
        background: var(--bg-input, #eef0f4);
        border: 1px solid var(--border-color, #e2e8f0);
        color: var(--text-secondary, #475569);
    }
    .site-header-lm .theme-btn {
        background: var(--bg-input, #eef0f4);
        color: var(--text-primary, #334155);
    }
    .site-header-lm .user-header-btn {
        background: var(--bg-input, #eef0f4);
        border: 1px solid var(--border-color, #e2e8f0);
        color: var(--text-primary, #334155);
    }

    [data-theme="dark"] .site-header-lm .header-lm-burger,
    [data-theme="dark"] .site-header-lm .header-lm-mobile-search {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(148, 163, 184, 0.25);
        color: #e2e8f0;
    }
    [data-theme="dark"] .site-header-lm .header-lm-burger:hover,
    [data-theme="dark"] .site-header-lm .header-lm-mobile-search:hover {
        background: rgba(255, 255, 255, 0.12);
    }
    [data-theme="dark"] .site-header-lm .header-lm-burger .header-lm-burger-lines span {
        background: #e2e8f0;
    }
    [data-theme="dark"] .site-header-lm .header-lm-menu-link {
        color: rgba(255, 255, 255, 0.85) !important;
    }
    [data-theme="dark"] .site-header-lm .header-lm-menu {
        border-top-color: rgba(148, 163, 184, 0.2);
    }
    [data-theme="dark"] .site-header-lm .header-lm-toolbar .header-right {
        border-top-color: rgba(148, 163, 184, 0.2);
    }

    /* 蓝色信息条：手机端不展示（去掉整段青绿提示区） */
    .site-header-lm .header-lm-sub {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
        border: none !important;
    }

    .site-header-lm .header-lm-logo-img.logo-icon {
        max-width: min(200px, 56vw);
        height: auto;
        min-height: 40px;
        max-height: 48px;
    }
    .site-header-lm .header-lm-logo-img.logo-icon img {
        object-fit: contain;
    }

    /* ——— 首页：白卡片目录风 ——— */
    body.page-home .main {
        padding: 12px 12px 24px;
    }

    body.page-home .cats-grid.box-list {
        display: flex;
        flex-direction: column;
        gap: 16px;
        grid-auto-rows: unset;
    }

    body.page-home .cats-grid .cat-card {
        grid-row: auto !important;
    }

    body.page-home .cats-grid .cat-card.box {
        height: auto;
        min-height: 0;
        margin: 0;
        border: 1px solid #d1d9e0;
        border-radius: 10px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
        background: #fff;
    }

    [data-theme="dark"] body.page-home .cats-grid .cat-card.box {
        background: var(--bg-card, #1a1a2e);
        border-color: rgba(148, 163, 184, 0.25);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    }

    body.page-home .cats-grid .cat-card.box h2.title {
        border-radius: 10px 10px 0 0;
    }

    body.page-home .cats-grid .cat-card.box ul.cat-site-list {
        max-height: 280px;
    }

    /* 站点列表手机两列（参考图） */
    body.page-home .cats-grid .cat-card.box ul.cat-site-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 8px;
        padding-left: 0.65rem;
        padding-right: 0.65rem;
    }
    body.page-home .cats-grid .cat-card.box li.row-line {
        border-bottom: 1px solid #eef0f4;
        padding: 6px 0;
    }

    /* 底部「查看更多」：全宽青灰按钮（参考图 SEE ALL） */
    body.page-home .cats-grid .cat-card.box .more-btn {
        padding: 0.65rem 12px 0.85rem;
    }
    body.page-home .cats-grid .cat-card.box .more-btn .view-more-link {
        width: 100% !important;
        max-width: none;
        margin: 0;
        padding: 12px 14px;
        border-radius: 8px;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: #fff !important;
        background: linear-gradient(180deg, #7a9aa3, #5f7a82) !important;
        border: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
    }
    body.page-home .cats-grid .cat-card.box .more-btn .view-more-link:hover {
        filter: brightness(1.05);
        color: #fff !important;
    }
    [data-theme="dark"] body.page-home .cats-grid .cat-card.box .more-btn .view-more-link {
        background: linear-gradient(180deg, #3d5a62, #2f454c) !important;
        color: #f8fafc !important;
    }

    body.page-home .footer {
        margin-top: 8px;
    }
}

/* 宽屏：隐藏手机专用控件（由默认样式接管） */
@media (min-width: 769px) {
    .site-header-lm .header-lm-burger,
    .site-header-lm .header-lm-mobile-search {
        display: none !important;
    }
}
