/* ============================================================
   Personal Home · 首页样式（pages/home.css）
   仅首页加载：Hero / 快捷入口 Tab / 项目展示
   依赖 base.css 的设计令牌与通用组件
   ============================================================ */

/* ---------- 首页卡片令牌：圆角 / 阴影沿用 base.css 的卡片规范 ---------- */
:root {
    --card-pad: 20px;
    --card-pad-sm: 16px;
    --card-gap: 16px;
    --status-online: #1d9a52;
    --status-online-soft: rgba(48, 209, 88, 0.13);
    --status-dev: #b8781a;
    --status-dev-soft: rgba(255, 176, 46, 0.16);
}

/* 暗色底上状态色需要提亮，否则徽标与进度数字对比度不足 */
@media (prefers-color-scheme: dark) {
    :root {
        --status-online: #4ed37f;
        --status-online-soft: rgba(78, 211, 127, 0.16);
        --status-dev: #f0bb62;
        --status-dev-soft: rgba(240, 187, 98, 0.18);
    }
}

/* ---------- Hero（手机纵排居中 / 桌面左右分布） ---------- */
.hero { padding: 0 0 2vh; }

.hero-card {
    /* 周期扫光的定位上下文；高光被圆角裁切 */
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(40px, 7vw, 68px) clamp(22px, 5vw, 48px);
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: clamp(20px, 3vw, 28px);
    border-radius: var(--radius-xl);
}

.hero-avatar-col { display: flex; }

.hero-info-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

/* 内容置于扫光之上，避免高光带掠过头像与文字影响阅读 */
.hero-avatar-col,
.hero-info-col {
    position: relative;
    z-index: 2;
}

.avatar {
    width: clamp(96px, 16vw, 116px);
    height: clamp(96px, 16vw, 116px);
    border-radius: 34%;
    object-fit: cover;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-card);
    background: var(--glass-strong);
}

.avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(38px, 7vw, 46px);
    font-weight: 700;
    color: #fff;
    background: var(--accent-grad);
}

.hero-name {
    margin-top: 26px;
    font-size: clamp(30px, 5.5vw, 42px);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
    text-wrap: balance;
}

.hero-tagline {
    margin-top: 10px;
    font-size: clamp(16px, 2.4vw, 18px);
    font-weight: 500;
    color: var(--fg-2);
}

.hero-bio {
    margin-top: 18px;
    max-width: 600px;
    font-size: clamp(14.5px, 2vw, 15.5px);
    color: var(--fg-2);
    text-wrap: pretty;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 22px;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 7px 15px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--fg-2);
    background: var(--glass-strong);
    border: 1px solid var(--hairline);
    box-shadow: inset 0 1px 0 var(--glass-hi);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-pill svg { width: 14px; height: 14px; }

.social-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 28px;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--touch);
    height: var(--touch);
    border-radius: 50%;
    color: var(--fg);
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-card);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease, color 0.25s ease;
}

.social-btn svg { width: 21px; height: 21px; }

/* 桌面：头像居左、信息靠右左对齐，内容横向分布 */
@media (min-width: 768px) {
    .hero-card {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        justify-items: start;
        text-align: left;
        gap: clamp(28px, 4vw, 48px);
        padding: clamp(36px, 5vw, 58px) clamp(30px, 5vw, 60px);
    }
    .hero-info-col { align-items: flex-start; }
    .hero-name { margin-top: 0; }
    .hero-meta, .social-row { justify-content: flex-start; }
}

/* ---------- 快捷入口 Tab（Hero 简介卡下方） ---------- */
.quick-tabs {
    margin: clamp(14px, 2.2vh, 22px) auto 0;
    padding: 6px;
    border-radius: 999px;
    background: var(--glass-grad);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-card);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.quick-tabs::-webkit-scrollbar { display: none; }

.quick-tabs-track {
    display: flex;
    gap: 4px;
    min-width: max-content;
}

.quick-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 44px;
    padding: 8px 14px;
    border-radius: 999px;
    color: var(--fg-2);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition:
        color var(--dur-sm) var(--ease-out),
        background var(--dur-sm) var(--ease-out),
        transform var(--dur-xs) var(--ease-out);
}

.quick-tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 10px;
    color: var(--accent);
    background: var(--accent-soft);
    transition: background var(--dur-sm) var(--ease-out);
}

.quick-tab-icon svg { width: 15px; height: 15px; }

.quick-tab-label { flex: 0 0 auto; }

/* 移动端：横向滚动 + 吸附；渐隐只在确实还能滚的一侧出现（状态类由 main.js 维护） */
@media (max-width: 719px) {
    .quick-tabs {
        scroll-snap-type: x proximity;
        scroll-padding-inline: 6px;
    }

    .quick-tabs .quick-tab { scroll-snap-align: start; }

    /* 右侧还有内容 */
    .quick-tabs.is-scrollable:not(.is-at-end) {
        -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
        mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 18px), transparent 100%);
    }

    /* 左侧已有内容滚出视口 */
    .quick-tabs.is-scrollable:not(.is-at-start) {
        -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 100%);
        mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 100%);
    }

    /* 两端都还有内容：双端渐隐（取两张蒙版的交集） */
    .quick-tabs.is-scrollable:not(.is-at-start):not(.is-at-end) {
        -webkit-mask-image:
            linear-gradient(90deg, transparent 0, #000 18px),
            linear-gradient(90deg, #000 calc(100% - 18px), transparent 100%);
        -webkit-mask-composite: source-in;
        mask-image:
            linear-gradient(90deg, transparent 0, #000 18px),
            linear-gradient(90deg, #000 calc(100% - 18px), transparent 100%);
        mask-composite: intersect;
    }
}

@media (min-width: 720px) {
    .quick-tabs { max-width: 880px; }
    .quick-tabs-track { justify-content: center; }
}

/* ---------- 项目区头部：标题 + 状态筛选（无刷新切换） ---------- */
.projects-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.projects-head > div:first-child { text-align: center; }

.project-filter {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    max-width: 100%;
    padding: 4px;
    border-radius: 999px;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 var(--glass-hi);
}

.project-filter button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg-2);
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.project-filter button span {
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(120, 120, 128, 0.14);
}

.project-filter button.is-active {
    color: #fff;
    background: var(--accent-grad);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.28);
}

.project-filter button.is-active span { background: rgba(255, 255, 255, 0.24); }

.project-filter button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* 筛选后隐藏的卡片：直接移出布局，切换即时生效无需刷新 */
.project-card.is-hidden { display: none; }

.project-empty {
    margin: 26px 0 0;
    text-align: center;
    font-size: 13.5px;
    color: var(--fg-3);
}

@media (min-width: 720px) {
    .projects-head {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
        gap: 20px;
    }
    .projects-head > div:first-child { text-align: left; }
    .projects-head .section-title,
    .projects-head .section-sub { text-align: left; }
}

/* ---------- 项目（手机单列 / 桌面两列等高网格） ---------- */
/* 网格而非瀑布流：DOM 顺序 = 视觉顺序 = 键盘顺序，筛选重排不跳动；
   同行卡片等高，底部 CTA 由 .project-links 的 margin-top:auto 对齐 */
.project-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--card-gap);
    margin-top: clamp(22px, 4vh, 30px);
}

.project-card {
    /* 扫光伪元素需要定位上下文；overflow 让高光停在卡片圆角内 */
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--card-radius);
    box-shadow:
        inset 0 1px 0 var(--glass-hi),
        inset 0 -1px 0 var(--glass-lo),
        var(--card-shadow);
    transition: transform var(--dur-md) var(--ease-out), box-shadow var(--dur-md) var(--ease-out);
}

/* 封面：比例跟随图片原图（PHP 写入 --cover-ratio），默认 16:10，超出范围由 CSS 兜底 */
.project-cover {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--hairline);
    aspect-ratio: var(--cover-ratio, 16 / 10);
    max-height: 320px;
    background: var(--glass-strong);
}

.project-cover-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.45s var(--ease-out);
}

/* 封面左下角的平台徽标（APK / Android / iOS / H5） */
.project-plats {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.project-plat {
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.5;
    color: #fff;
    background: rgba(8, 12, 22, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.2);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.project-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--card-pad);
}

.project-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }

.project-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.35; min-width: 0; }

/* 状态徽标：已上线（绿）/ 开发中（琥珀） */
.project-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

.project-status i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.project-status.is-online { color: var(--status-online); background: var(--status-online-soft); }
.project-status.is-dev { color: var(--status-dev); background: var(--status-dev-soft); }

.project-year {
    margin-left: auto;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
}

/* 开发进度：文字 + 细进度条，仅「开发中」项目展示 */
.project-progress { margin-top: 14px; }

.project-progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
    font-size: 12.5px;
    color: var(--fg-3);
}

.project-progress-head b {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: var(--status-dev);
}

.project-progress-bar {
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--status-dev-soft);
}

.project-progress-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ffd479, #ffad3d);
    transition: width 0.6s var(--ease-out);
}

/* 简介默认两行：长文案不把卡片撑得过高，列表节奏保持一致 */
.project-summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    margin-top: 8px;
    overflow: hidden;
    overflow-wrap: break-word;
    font-size: 14px;
    line-height: 1.65;
    color: var(--fg-2);
    text-wrap: pretty;
}

/* 展开后显示完整简介：不删除、不截断用户文字 */
.project-summary.is-expanded,
.project-summary.is-measuring {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}

/* 「展开全文 / 收起」由 JS 在确实被截断时才显示 */
.project-more {
    align-self: flex-start;
    margin-top: 8px;
    padding: 2px 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.6;
    cursor: pointer;
    touch-action: manipulation;
    transition: color var(--dur-sm) var(--ease-out), opacity var(--dur-xs) linear;
}

.project-more[hidden] { display: none; }
.project-more:active { opacity: 0.7; }
.project-more:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

@media (hover: hover) and (pointer: fine) {
    .project-more:hover {
        color: var(--accent-2);
        text-decoration: underline;
        text-underline-offset: 3px;
    }
}

.tech-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.tech-tag {
    padding: 5px 13px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-2);
    background: var(--glass-strong);
    border: 1px solid var(--hairline);
    box-shadow: inset 0 1px 0 var(--glass-hi);
}

.project-links { display: flex; gap: 10px; margin-top: auto; padding-top: 16px; }

.link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    background: var(--accent-grad);
    box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.30);
    transition: transform var(--dur-sm) var(--ease-out), box-shadow var(--dur-sm) var(--ease-out);
}

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

.link-btn-ghost {
    color: var(--fg);
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 var(--glass-hi);
}

/* ---------- 交互增强（指针精细设备）：首页卡片悬浮抬升 ---------- */
@media (hover: hover) and (pointer: fine) {
    .social-btn:hover { transform: translateY(-4px) scale(1.05); box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-lift); color: var(--accent); }
    .project-card:hover {
        transform: translateY(-5px);
        background: var(--glass-grad-hover);
        box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 var(--glass-lo), var(--card-shadow-hover);
    }
    .quick-tab:hover {
        color: var(--accent);
        background: var(--glass-grad-hover);
    }
    .quick-tab:hover .quick-tab-icon { background: rgba(var(--accent-rgb), 0.22); }
    .project-card:hover .project-cover-img { transform: scale(1.025); }
    .link-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(var(--accent-rgb), 0.38); }
    .link-btn-ghost:hover { box-shadow: inset 0 1px 0 var(--glass-hi), var(--shadow-card); }
}

/* ---------- 扫光：卡片玻璃表面的斜向高光掠过 ----------
   伪元素只做一条窄斜带，动画仅改 transform / opacity，由合成层完成，
   不触发重绘；触摸设备、粗指针与“减少动态效果”下不启用。
   强度控制得比纯白更低，避免刺眼与廉价感。 */
.project-card::after {
    content: "";
    position: absolute;
    top: -30%;
    bottom: -30%;
    left: -45%;
    width: 18%;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(
        100deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.38) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: translate3d(-180%, 0, 0) rotate(14deg);
}

@media (hover: hover) and (pointer: fine) {
    .project-card:hover::after {
        will-change: transform, opacity;
        animation: card-sheen 0.85s var(--ease-out) both;
    }
}

@keyframes card-sheen {
    0%   { opacity: 0;   transform: translate3d(-180%, 0, 0) rotate(14deg); }
    30%  { opacity: 0.6; }
    100% { opacity: 0;   transform: translate3d(560%, 0, 0) rotate(14deg); }
}

/* Hero 大卡片的周期扫光：桌面 12s 轻掠一次；
   触摸设备使用更克制的低频版本（见下方触摸媒体查询），
   两者都只做 transform / opacity 动画。 */
.hero-card::after {
    content: "";
    position: absolute;
    top: -30%;
    bottom: -30%;
    left: -40%;
    width: 14%;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(
        100deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.34) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: translate3d(-260%, 0, 0) rotate(12deg);
}

@media (hover: hover) and (pointer: fine) {
    .hero-card::after {
        animation: hero-sheen 12s var(--ease-in-out) 1.2s infinite;
    }
}

@keyframes hero-sheen {
    0%       { opacity: 0;   transform: translate3d(-260%, 0, 0) rotate(12deg); }
    8%       { opacity: var(--hero-sheen-peak, 0.55); }
    20%      { opacity: 0;   transform: translate3d(760%, 0, 0) rotate(12deg); }
    100%     { opacity: 0;   transform: translate3d(760%, 0, 0) rotate(12deg); }
}

/* 深色底上白光过强会显脏，压低到刚好能看见的强度 */
@media (prefers-color-scheme: dark) {
    .project-card::after {
        background: linear-gradient(
            100deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.11) 50%,
            rgba(255, 255, 255, 0) 100%
        );
    }
    .hero-card::after {
        background: linear-gradient(
            100deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.09) 50%,
            rgba(255, 255, 255, 0) 100%
        );
    }
}

/* ---------- 交互增强（触摸设备）：首页按压反馈 ---------- */
@media (hover: none) {
    .social-row { gap: 14px; }
    .hero-meta { gap: 12px; }
    .link-btn { min-height: 44px; padding: 0 20px; touch-action: manipulation; }

    /* 按压反馈更跟手（缩短过渡） */
    .project-card {
        touch-action: manipulation;
        -webkit-user-select: none;
        user-select: none;
        transition: transform 0.14s ease, background 0.2s ease;
    }
    .project-card:active {
        transform: scale(0.975);
        background: var(--glass-grad-hover);
    }
    .quick-tab:active { transform: scale(0.97); color: var(--accent); }
    .social-btn:active { transform: scale(0.92); color: var(--accent); }
    .link-btn:active { transform: scale(0.96); filter: brightness(1.06); }

    .tech-tag, .meta-pill { user-select: none; }
}

/* 触摸设备（无 hover 或粗指针）：保留 Hero 扫光，但周期更长、光带更窄、峰值更低；
   全站仅 Hero 一个元素做周期扫动，项目卡扫光只在精细指针 hover 时触发，不会同步扫动。 */
@media (hover: none), (pointer: coarse) {
    .hero-card::after {
        width: 10%;
        --hero-sheen-peak: 0.3;
        animation: hero-sheen 24s var(--ease-in-out) 3s infinite;
    }
}

/* ---------- 动效降级：首页 ---------- */
@media (prefers-reduced-motion: reduce) {
    .project-card, .social-btn, .link-btn, .quick-tab { transition: none; }
    .project-cover-img { transition: none; }
    /* 关闭扫光：保留静态卡片，不做任何扫掠动画 */
    .hero-card::after, .project-card::after { display: none; }
}

/* ---------- 响应式：项目两列等高网格 ---------- */
@media (min-width: 720px) {
    /* 宽屏两列：同行等高，底部 CTA 对齐；顺序为从左到右，而非列优先 */
    .project-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 响应式：手机（首页专属） ---------- */
@media (max-width: 640px) {
    /* 首屏更紧凑：让「简介 + 快捷入口」在常见手机上一屏可见 */
    .hero { padding: 0 0 6px; }

    .hero-card {
        padding: 30px 20px 28px;
        gap: 18px;
        border-radius: var(--radius-lg);
    }

    .avatar {
        width: 88px;
        height: 88px;
    }

    .hero-name {
        margin-top: 18px;
        font-size: clamp(26px, 8vw, 32px);
    }

    .hero-bio {
        margin-top: 14px;
        line-height: 1.7;
    }

    .hero-meta { margin-top: 18px; }
    .social-row { margin-top: 22px; }

    /* 项目区间距收紧，滚动路径更短 */
    .section { padding: 30px 0; }

    .project-cover { max-height: 300px; }

    .project-body { padding: var(--card-pad-sm); }

    /* 窄屏单列：标题略降一级，简介放宽到三行 */
    .project-name { font-size: 17px; }

    .project-summary {
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }

    .project-links .link-btn { flex: 1; justify-content: center; }
}

/* 锚点跳转时给固定顶栏留位置，标题不被遮住 */
#about,
#projects {
    scroll-margin-top: 84px;
}

/* ---------- 响应式：小屏手机 ---------- */
@media (max-width: 400px) {
    .hero-meta { width: 100%; }
    .meta-pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tech-tags { gap: 6px; }

    /* 项目状态筛选：小屏铺满一行，按钮均分宽度，避免横向溢出 */
    .project-filter {
        width: 100%;
        border-radius: 16px;
    }

    .project-filter button {
        flex: 1 1 0;
        justify-content: center;
        padding: 8px 8px;
    }
}

/* ============================================================
   项目下载弹层（桌面居中 Modal / 手机底部抽屉）
   ============================================================ */
.p-sheet {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.p-sheet[hidden] { display: none; }

.p-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 9, 16, 0.52);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    animation: p-sheet-fade var(--dur-sm) var(--ease-out) both;
}

/* 退场：JS 先加 .is-closing 播放收起动画，动画结束后再真正隐藏 */
.p-sheet.is-closing .p-sheet-backdrop { animation: p-sheet-fade-out 0.2s var(--ease-out) forwards; }
.p-sheet.is-closing .p-sheet-panel { animation: p-sheet-down 0.22s var(--ease-out) forwards; }

.p-sheet-panel {
    position: relative;
    width: min(520px, 100%);
    max-height: min(82vh, 640px);
    max-height: min(82dvh, 640px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    /* 不透明面板：避免下方正文透出影响阅读 */
    background: var(--bg);
    border: 1px solid var(--hairline);
    border-bottom: 0;
    box-shadow: 0 -12px 44px rgba(0, 0, 0, 0.22);
    animation: p-sheet-up 0.3s var(--ease-out);
}

.p-sheet-handle {
    display: block;
    width: 38px;
    height: 4px;
    margin: 6px auto 6px;
    border-radius: 999px;
    background: var(--hairline);
}

.p-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 2px 14px;
}

.p-sheet-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.p-sheet-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--fg-2);
    background: var(--glass-strong);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.p-sheet-close svg { width: 15px; height: 15px; }
.p-sheet-close:hover { color: var(--fg); }

.p-sheet-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: var(--fg);
    text-decoration: none;
    background: var(--glass-strong);
    border: 1px solid var(--hairline);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.p-sheet-item + .p-sheet-item { margin-top: 9px; }

.p-sheet-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    color: #fff;
    background: var(--accent-grad);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.26);
}

.p-sheet-icon svg { width: 19px; height: 19px; }

.p-sheet-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.p-sheet-text strong { font-size: 14.5px; font-weight: 600; }
.p-sheet-text small { margin-top: 2px; font-size: 12.5px; color: var(--fg-3); }

.p-sheet-go {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: var(--fg-3);
}

@keyframes p-sheet-fade {
    from { opacity: 0; }
}

@keyframes p-sheet-fade-out {
    to { opacity: 0; }
}

@keyframes p-sheet-up {
    from { opacity: 0; transform: translateY(22px); }
}

@keyframes p-sheet-down {
    to { opacity: 0; transform: translateY(26px); }
}

@keyframes p-sheet-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
}

@keyframes p-sheet-pop-out {
    to { opacity: 0; transform: translateY(8px) scale(0.97); }
}

/* 交互增强：下载项悬浮反馈 */
@media (hover: hover) and (pointer: fine) {
    .p-sheet-item:hover { background: var(--glass-strong); border-color: var(--glass-border); transform: translateY(-1px); }
}

/* 触摸端：按下即时有反馈，弥补没有 hover 的感知缺失 */
@media (hover: none) {
    .p-sheet-item:active { background: var(--accent-soft); border-color: var(--accent); transform: scale(0.985); }
    .p-sheet-close:active { transform: scale(0.9); }
}

/* 桌面：改为居中模态框 */
@media (min-width: 641px) {
    .p-sheet { align-items: center; padding: 24px; }
    .p-sheet-panel {
        padding: 16px 20px 20px;
        border-bottom: 1px solid var(--glass-edge);
        border-radius: var(--radius-xl);
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
        animation: p-sheet-pop var(--dur-md) var(--ease-spring) both;
    }
    .p-sheet.is-closing .p-sheet-panel { animation: p-sheet-pop-out 0.2s var(--ease-out) forwards; }
    .p-sheet-handle { display: none; }
}

/* 弹层打开时锁定页面滚动 */
body.sheet-lock { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .p-sheet-backdrop, .p-sheet-panel { animation: none; }
    .p-sheet-item { transition: none; }
}