/**
 * Legado 资源加速下载 - 主题样式
 * 单页交互：资源列表 + 详情侧栏，无需跳转二级页面
 */

/* ===================== 设计令牌 ===================== */
:root {
    color-scheme: light;

    --bg: #FAFAFC;
    --surface: #FFFFFF;
    --surface-2: #F4F4F8;
    --surface-3: #EDEDF3;
    --border: #E6E6EE;
    --border-strong: #D4D4E0;

    --text: #17171C;
    --text-secondary: #55555F;
    --text-muted: #83838F;

    --accent: #3B82F6;
    --accent-hover: #2563EB;
    --accent-contrast: #FFFFFF;
    --accent-soft: rgba(59, 130, 246, 0.09);
    --accent-soft-strong: rgba(59, 130, 246, 0.16);

    --success: #14713A;
    --success-soft: rgba(20, 113, 58, 0.10);
    --success-soft-strong: rgba(20, 113, 58, 0.28);
    --warning: #8A5200;
    --warning-soft: rgba(138, 82, 0, 0.12);
    --danger: #B42318;
    --danger-soft: rgba(180, 35, 24, 0.10);

    /* 发布状态语义色：推荐=绿、预发布=橙、正式版=蓝 */
    --info: #1F6FBF;
    --info-soft: rgba(31, 111, 191, 0.10);

    /* 触摸目标最小尺寸，移动端可点击热区基准 */
    --tap: 44px;

    --shadow-sm: 0 1px 2px rgba(18, 18, 25, 0.05);
    --shadow-md: 0 4px 14px rgba(18, 18, 25, 0.07);
    --shadow-lg: 0 18px 48px rgba(18, 18, 25, 0.16);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', system-ui, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --nav-h: 58px;
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0F0F11;
    --surface: #16161D;
    --surface-2: #1D1D25;
    --surface-3: #24242E;
    --border: #282833;
    --border-strong: #363642;

    --text: #EFEFF3;
    --text-secondary: #B3B3C0;
    --text-muted: #89899A;

    --accent: #60A5FA;
    --accent-hover: #93C5FD;
    --accent-contrast: #0F0F11;
    --accent-soft: rgba(96, 165, 250, 0.14);
    --accent-soft-strong: rgba(96, 165, 250, 0.24);

    --success: #5CD68A;
    --success-soft: rgba(92, 214, 138, 0.14);
    --success-soft-strong: rgba(92, 214, 138, 0.34);
    --warning: #E8B04B;
    --warning-soft: rgba(232, 176, 75, 0.15);
    --danger: #FF9086;
    --danger-soft: rgba(255, 144, 134, 0.14);

    --info: #6FB4F7;
    --info-soft: rgba(111, 180, 247, 0.15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.6);
}

/* ===================== 基础 ===================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img,
svg {
    display: block;
    max-width: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.18s var(--ease);
}

a:hover {
    color: var(--accent-hover);
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

input {
    font: inherit;
    color: inherit;
}

::selection {
    background: var(--accent-soft-strong);
}

/* 滚动条 */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-strong);
    border-radius: var(--radius-pill);
    border: 3px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
    background-clip: content-box;
}

/* 焦点可见性 */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    left: 16px;
    top: -60px;
    z-index: 200;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    background-color: var(--accent);
    color: var(--accent-contrast);
    font-size: 14px;
    font-weight: 500;
    transition: top 0.2s var(--ease);
}

.skip-link:focus {
    top: 12px;
    color: var(--accent-contrast);
}

/* ===================== 布局 ===================== */
.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===================== 顶栏 ===================== */
.nav {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--nav-h);
    background-color: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

@supports not (background-color: color-mix(in srgb, red 50%, transparent)) {
    .nav {
        background-color: var(--bg);
    }
}

.nav-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    min-width: 0;
}

.nav-brand:hover {
    color: var(--text);
}

/* logo 为横宽比例，固定高度让宽度自适应，避免强塞正方形导致压缩或裁切 */
.nav-brand img {
    height: 26px;
    width: auto;
    flex-shrink: 0;
}

.nav-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* 图标按钮 */
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}

.icon-btn:hover {
    background-color: var(--surface-2);
    color: var(--text);
}

/* ===================== 头部 ===================== */
.hero {
    padding: 52px 0 32px;
    text-align: center;
}

.hero h1 {
    font-size: 34px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text);
}

.hero p {
    margin-top: 12px;
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

/* 公告条 */
.notice {
    max-width: 720px;
    margin: 24px auto 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background-color: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    text-align: left;
}

.notice-icon {
    flex-shrink: 0;
    color: var(--accent);
}

.notice-viewport {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}

.notice-track {
    display: inline-flex;
    gap: 48px;
    white-space: nowrap;
    animation: notice-scroll 32s linear infinite;
}

.notice:hover .notice-track,
.notice:focus-within .notice-track {
    animation-play-state: paused;
}

.notice-item {
    font-size: 13px;
    color: var(--text-secondary);
}

.notice-item:hover {
    color: var(--accent);
}

@keyframes notice-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* ===================== 工具栏 ===================== */
.toolbar {
    position: sticky;
    top: var(--nav-h);
    z-index: 50;
    padding: 14px 0;
    background-color: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-bottom: 8px;
}

@supports not (background-color: color-mix(in srgb, red 50%, transparent)) {
    .toolbar {
        background-color: var(--bg);
    }
}

.toolbar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* 搜索框 */
.search {
    position: relative;
    flex: 1 1 260px;
    min-width: 200px;
    max-width: 340px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 38px;
    padding: 0 34px 0 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background-color: var(--surface);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.search input::placeholder {
    color: var(--text-muted);
}

.search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.search-clear:hover {
    background-color: var(--surface-2);
    color: var(--text);
}

/* 筛选胶囊 */
.filters {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-btn {
    height: 32px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.18s var(--ease);
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.filter-btn.active {
    background-color: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

/* 筛选按钮计数气泡 */
.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background-color: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}

.filter-btn:hover .filter-count {
    background-color: var(--surface-3);
    color: var(--text-secondary);
}

.filter-btn.active .filter-count {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--bg);
}

[data-theme="dark"] .filter-btn.active .filter-count {
    background-color: rgba(0, 0, 0, 0.2);
}

/* ===================== 资源网格 ===================== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
    padding-bottom: 8px;
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    text-align: left;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* 卡片整体可点击：标题链接伸展覆盖整张卡片 */
.card-link {
    color: inherit;
    text-decoration: none;
    outline: none;
}

.card-link::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}

/* 标题下方第二行：仓库入口与热度数据 */
.card-subline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    min-width: 0;
    margin: -4px 0 12px;
    color: var(--text-muted);
    font-size: 11.5px;
}

/* 独立的 GitHub 链接需要浮在卡片详情热区之上 */
.card-repo-link {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    max-width: min(100%, 260px);
    padding: 3px 6px;
    border-radius: 5px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10.5px;
    line-height: 1.3;
    text-decoration: none;
    transition: color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.card-repo-link:hover {
    color: var(--accent);
    background-color: var(--accent-soft);
}

.card-repo-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.card-repo-link img {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.card-repo-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: -0.01em;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

/* 角标组：固定在卡片右上角，不随内容换行下沉 */
.card-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.card-desc {
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 14px;
}

.card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.card-spacer {
    flex: 1;
}

.card-foot {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.card-repo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11.5px;
}

.card-repo-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-repo img {
    flex-shrink: 0;
    opacity: 0.7;
}

    /* 手机端第二行允许仓库名与热度数据自然换行 */
    .card-subline {
        gap: 5px 10px;
        margin-bottom: 12px;
    }

    .card-repo-link {
        max-width: 100%;
        padding-left: 0;
    }

    .card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    font-size: 12px;
}

/* 字体与 .card-repo-link 保持一致，让第二行视觉统一 */
.card-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.card-stat-icon {
    flex-shrink: 0;
    opacity: 0.7;
}

.card-stale {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: var(--warning-soft);
    color: var(--warning);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
}

/* Release 时间：图标与文本始终保持同一行 */
.card-release-date {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 4px;
    min-width: max-content;
    white-space: nowrap;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.card-release-icon {
    display: block;
    flex: 0 0 auto;
    opacity: 0.7;
}

/* 推荐卡片：绿色系与推荐角标保持一致，避免一张卡出现两个焦点色 */
.card.recommended {
    border-color: var(--success-soft-strong);
    background-image: linear-gradient(to bottom, var(--success-soft) 0, transparent 88px);
}

/* 顶部色条：整卡最强的识别信号，同时不占额外高度 */
/*
 * 顶部色条与卡片外沿严格等宽：
 * 1. 负 1px 偏移抵消边框（绝对定位以 padding box 为基准，需外扩覆盖 border）
 * 2. 高度取满卡片圆角半径，再用 border-radius 继承卡片弧线，
 *    避免 3px 矮元素触发圆角等比压缩导致两端弧线对不上
 * 3. clip-path 只保留顶部 3px，形状由圆角决定而非硬切
 */
.card.recommended::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    height: calc(var(--radius-lg) + 1px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background-color: var(--success);
    clip-path: inset(0 0 calc(100% - 4px) 0);
}

.card.recommended:hover {
    border-color: var(--success);
    box-shadow: var(--shadow-md), 0 0 0 3px var(--success-soft);
}

.card.recommended .card-title {
    font-weight: 700;
}

/* 焦点态置于推荐样式之后，确保键盘焦点环在推荐卡片上同样可见 */
.card:focus-within,
.card.recommended:focus-within {
    border-color: var(--accent);
    box-shadow: var(--shadow-md), 0 0 0 3px var(--accent-soft-strong);
}

/* ===================== 徽章 ===================== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 9px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--surface-2);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
}

.chip-accent {
    background-color: var(--accent-soft);
    border-color: transparent;
    color: var(--accent);
}

.chip-success {
    background-color: var(--success-soft);
    border-color: transparent;
    color: var(--success);
}

.chip-warning {
    background-color: var(--warning-soft);
    border-color: transparent;
    color: var(--warning);
}

.chip-mono {
    font-family: var(--font-mono);
    font-size: 11.5px;
}

/* ===================== 状态角标 ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    height: 21px;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

/* 推荐角标：实心底色，在一排角标中优先被看到 */
.badge-recommended {
    gap: 5px;
    background-color: var(--success);
    border-color: var(--success);
    color: #FFFFFF;
}

.badge-recommended::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: currentColor;
}

[data-theme="dark"] .badge-recommended {
    color: #0D2A18;
}

.badge-prerelease {
    background-color: var(--warning-soft);
    border-color: var(--warning-soft);
    color: var(--warning);
}

.badge-stable {
    background-color: var(--info-soft);
    border-color: var(--info-soft);
    color: var(--info);
}

/* ===================== 按钮 ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.18s var(--ease);
}

/* 大号按钮：主要行动点，热区对齐触摸目标基准 */
.btn-lg {
    min-height: var(--tap);
    height: auto;
    padding: 0 22px;
    border-radius: var(--radius-pill);
    font-size: 14.5px;
    font-weight: 600;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--accent-contrast);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    color: var(--accent-contrast);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-primary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* GitHub 图标为深色 PNG，压在强调色上需反色才够清晰 */
.btn-primary img {
    filter: brightness(0) invert(1);
}

[data-theme="dark"] .btn-primary img {
    filter: brightness(0);
}

.btn-ghost {
    border-color: var(--border);
    background-color: var(--surface);
    color: var(--text);
}

.btn-ghost:hover {
    border-color: var(--border-strong);
    background-color: var(--surface-2);
    color: var(--text);
}

/* ===================== 空状态 ===================== */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 64px 24px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 14px;
}

/* ===================== 详情侧栏 ===================== */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.28s var(--ease);
}

.sheet-backdrop.open {
    opacity: 1;
}

.sheet {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    width: min(700px, 100%);
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.32s var(--ease);
}

.sheet.open {
    transform: translateX(0);
}

.sheet-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background-color: var(--surface);
    flex-shrink: 0;
}

.sheet-head-main {
    flex: 1;
    min-width: 0;
}

.sheet-eyebrow {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.sheet-title {
    font-size: 19px;
    font-weight: 650;
    letter-spacing: -0.015em;
    color: var(--text);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.sheet-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

body.sheet-open {
    overflow: hidden;
}

/* 加载骨架 */
.skeleton-line {
    height: 12px;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.3s ease-in-out infinite;
    margin-bottom: 12px;
}

.skeleton-block {
    height: 96px;
    border-radius: var(--radius-md);
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.3s ease-in-out infinite;
    margin-bottom: 12px;
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===================== 详情内容 ===================== */
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.detail-desc {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 16px;
    overflow-wrap: anywhere;
}

/* 统计与仓库入口同一行：统计靠左，主按钮靠右 */
.detail-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.detail-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* 统计项：卡片化，数值为主、标签为辅 */
.stat {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface-2);
    font-size: 13px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.stat svg {
    flex-shrink: 0;
    color: var(--accent);
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* 版本 */
.release {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    margin-bottom: 12px;
}

/* 最新版本：高亮边框，视觉上先被看到 */
.release-latest {
    border-color: var(--success);
    box-shadow: 0 0 0 1px var(--success), var(--shadow-sm);
}

.release-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.release-head-main {
    min-width: 0;
    flex: 1 1 200px;
}

.release-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.release-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    overflow-wrap: anywhere;
}

.release-date {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* 版本说明（原生折叠） */
.notes {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface-2);
    margin-bottom: 14px;
}

/* 折叠头：热区拉满一行，高度对齐触摸目标基准 */
.notes > summary {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 12px 15px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
    border-radius: var(--radius-md);
    transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}

.notes > summary::-webkit-details-marker {
    display: none;
}

.notes > summary:hover {
    background-color: var(--surface-3);
    color: var(--text);
}

.notes > summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.notes[open] > summary {
    color: var(--text);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* 箭头放进圆形底座，指向更明确 */
.notes > summary::after {
    content: '';
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-left: auto;
    border-radius: 50%;
    background-color: var(--surface-3);
    box-shadow: inset 0 0 0 1px var(--border);
    transition: background-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

/* 箭头本体：绝对定位到圆形底座中心 */
.notes > summary::before {
    content: '';
    position: absolute;
    right: 22px;
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.22s var(--ease);
    pointer-events: none;
    z-index: 1;
}

.notes[open] > summary::before {
    transform: rotate(-135deg) translateY(-2px);
}

.notes > summary:hover::after {
    background-color: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent-soft-strong);
}

.notes-body {
    padding: 12px 15px 15px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.75;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
    max-height: 300px;
    overflow-y: auto;
}

/* 版本说明内的 Markdown 元素：紧凑排版，避免撑开折叠区 */
.notes-body > :first-child {
    margin-top: 0;
}

.notes-body > :last-child {
    margin-bottom: 0;
}

.notes-body p {
    margin: 0 0 8px;
}

.notes-body h1,
.notes-body h2,
.notes-body h3,
.notes-body h4,
.notes-body h5,
.notes-body h6 {
    margin: 14px 0 6px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text);
}

/* release notes 内标题降级，不与页面标题层级竞争 */
.notes-body h1 { font-size: 15px; }
.notes-body h2 { font-size: 14px; }
.notes-body h3,
.notes-body h4,
.notes-body h5,
.notes-body h6 { font-size: 13px; }

.notes-body ul,
.notes-body ol {
    margin: 0 0 8px;
    padding-left: 20px;
}

.notes-body li {
    margin-bottom: 3px;
}

.notes-body a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.notes-body a:hover {
    text-decoration-thickness: 2px;
}

.notes-body strong {
    font-weight: 700;
    color: var(--text);
}

.notes-body code {
    padding: 1px 5px;
    border-radius: 4px;
    background-color: var(--surface-3);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.92em;
    overflow-wrap: anywhere;
}

.notes-body pre {
    margin: 0 0 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface-3);
    overflow-x: auto;
}

/* 代码块内的 code 去掉行内样式，避免双层背景 */
.notes-body pre code {
    padding: 0;
    background: none;
    border-radius: 0;
    white-space: pre;
    overflow-wrap: normal;
}

/* 下载项：主色调按钮样式，大圆角 + 大热区 */
.asset-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.asset {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--tap);
    padding: 12px 16px;
    border: 1px solid var(--accent-soft-strong);
    border-radius: var(--radius-pill);
    background-color: var(--accent-soft);
    color: var(--accent);
    transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.asset:hover {
    border-color: transparent;
    background-color: var(--accent);
    color: var(--accent-contrast);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

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

.asset-icon {
    flex-shrink: 0;
    color: currentColor;
}

.asset-name {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 文件大小：置于按钮右侧，随按钮状态反色 */
.asset-size {
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background-color: var(--surface);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}

.asset:hover .asset-size {
    background-color: rgba(255, 255, 255, 0.22);
    color: var(--accent-contrast);
}

/* 深色主题下强调色为亮紫，叠加层改为暗色才有足够对比 */
[data-theme="dark"] .asset:hover .asset-size {
    background-color: rgba(0, 0, 0, 0.18);
}

/* ---------- 复制下载链接 ---------- */
/* 下载项包裹容器：让复制按钮与下载链接并列，避免嵌套可点击元素 */
.asset-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.asset-row .asset {
    flex: 1;
    min-width: 0;
}

.asset-copy {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease), color 0.18s var(--ease);
}

.asset-copy:hover {
    border-color: var(--accent);
    background-color: var(--accent-soft);
    color: var(--accent);
}

.asset-copy:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* 复制成功：短暂反馈，2 秒后由 JS 移除 */
.asset-copy.copied {
    border-color: transparent;
    background-color: var(--success, #2e7d32);
    color: #fff;
}

.asset-copy .icon-copied {
    display: none;
}

.asset-copy.copied .icon-copy {
    display: none;
}

.asset-copy.copied .icon-copied {
    display: block;
}

/* ===================== 提示框 ===================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 15px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    border: 1px solid transparent;
}

.alert svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-info {
    background-color: var(--accent-soft);
    color: var(--accent);
}

.alert-warning {
    background-color: var(--warning-soft);
    color: var(--warning);
}

.alert-danger {
    background-color: var(--danger-soft);
    color: var(--danger);
}

.alert-muted {
    background-color: var(--surface-2);
    border-color: var(--border);
    color: var(--text-muted);
}

/* ===================== 页脚 ===================== */
.footer {
    margin-top: 48px;
    padding: 28px 0 40px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.footer a {
    color: var(--text-secondary);
}

.footer a:hover {
    color: var(--accent);
}

.footer-sep {
    margin: 0 8px;
    opacity: 0.5;
}

/* ===================== 独立详情页（无 JS 回退） ===================== */
.page-detail {
    padding: 32px 0 0;
    max-width: 780px;
    margin: 0 auto;
}

.page-detail-head {
    margin-bottom: 20px;
}

.page-detail-head h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

/* 返回按钮：实体样式，热区达到触摸目标基准 */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 16px 0 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background-color: var(--surface);
    box-shadow: var(--shadow-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 18px;
    transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}

.back-link svg {
    transition: transform 0.18s var(--ease);
}

.back-link:hover {
    border-color: var(--accent);
    background-color: var(--accent-soft);
    color: var(--accent);
}

/* 箭头随 hover 左移，强化“返回”方向感 */
.back-link:hover svg {
    transform: translateX(-2px);
}

.back-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===================== 响应式 ===================== */
@media (max-width: 860px) {
    .hero {
        padding: 36px 0 24px;
    }

    .hero h1 {
        font-size: 27px;
    }

    .hero p {
        font-size: 14px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 14px;
    }

    .hero {
        padding: 28px 0 20px;
    }

    .hero h1 {
        font-size: 23px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .search {
        flex: 1 1 100%;
        max-width: none;
    }

    .filters {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .filters::-webkit-scrollbar {
        display: none;
    }

    .sheet {
        width: 100%;
        border-left: none;
    }

    .sheet-head,
    .sheet-body {
        padding: 16px;
    }

    .sheet-title {
        font-size: 17px;
    }

    .card-release-date {
        flex-basis: 100%;
        margin-left: 0;
        min-width: 0;
        width: max-content;
        max-width: 100%;
    }

    /* 窄屏换行后按钮占满整行，避免孤立右对齐 */
    .detail-bar {
        gap: 14px;
    }

    .detail-actions {
        margin-left: 0;
        width: 100%;
    }

    .detail-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* 移动端文件名允许换行，避免长文件名被截断无法阅读 */
    .asset {
        align-items: flex-start;
    }

    .asset-icon {
        margin-top: 2px;
    }

    .asset-name {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .notice {
        margin-left: 0;
        margin-right: 0;
    }
}

/* ===================== 触摸设备 ===================== */
/* 触摸屏无真实 hover，改用按压反馈，避免 hover 态粘滞 */
@media (hover: none) {
    .card:hover {
        transform: none;
        border-color: var(--border);
        box-shadow: var(--shadow-sm);
    }

    .card:active {
        transform: scale(0.985);
        border-color: var(--accent-soft-strong);
        box-shadow: var(--shadow-md);
    }

    /* 触摸设备复位 hover 时，保留推荐卡片的绿色识别 */
    .card.recommended:hover {
        border-color: var(--success-soft-strong);
        box-shadow: var(--shadow-sm);
    }

    .card.recommended:active {
        border-color: var(--success);
        box-shadow: var(--shadow-md), 0 0 0 3px var(--success-soft);
    }

    .asset:active {
        transform: scale(0.985);
    }

    .btn:active {
        transform: scale(0.97);
    }

    .filter-btn:active {
        background-color: var(--accent-soft);
    }
}

/* ===================== 动效偏好 ===================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .notice-track {
        animation: none;
        white-space: normal;
    }

    .card:hover {
        transform: none;
    }

    .card:active,
    .asset:active,
    .btn:active {
        transform: none;
    }

    .sheet {
        transition: none;
    }
}

/* ===================== 分类分组 ===================== */
.category-group {
    margin-bottom: 2rem;
}

.category-group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.01em;
}

.category-group-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.25rem;
    padding: 0 0.4rem;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.category-group[hidden] {
    display: none;
}

/* ===================== 自定义下载入口 ===================== */
.custom-download {
    margin-top: 1.25rem;
    margin-bottom: 0;
}

.custom-download-inner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
}

.custom-download-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    letter-spacing: 0.01em;
}

.custom-download-row {
    display: flex;
    gap: 0.625rem;
    align-items: stretch;
}

.custom-repo-input {
    flex: 1;
    min-width: 0;
    height: var(--tap);
    padding: 0 0.875rem;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.custom-repo-input::placeholder {
    color: var(--text-muted);
}

.custom-repo-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--surface);
}

.custom-repo-submit {
    flex-shrink: 0;
    height: var(--tap);
    padding: 0 1.125rem;
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
    white-space: nowrap;
}

.custom-repo-submit:hover {
    background: var(--accent-hover);
}

.custom-repo-submit:active {
    transform: scale(0.97);
}

.custom-repo-submit:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.custom-repo-error {
    margin-top: 0.4rem;
    font-size: 0.8125rem;
    color: var(--danger);
    min-height: 0;
}

.custom-repo-error:not(:empty) {
    min-height: 1.25rem;
}

@media (max-width: 480px) {
    .custom-download-row {
        flex-direction: column;
    }

    .custom-repo-submit {
        width: 100%;
    }
}
