/* GitHub 热榜（/tools/github-hot）样式
 *
 * 约定：
 *  1. class 前缀 gh-；配色一律消费站点主题变量，**深色为默认基线**，浅色由 [data-theme="light"] 覆盖
 *     （与站内 nginx_config / iphone17 / miniapp 等页面同一套手法：html[data-theme]，见 style.css）。
 *  2. 本站多处以 display:flex 声明容器，凡用 hidden 属性控制显隐的元素
 *     都必须补 [hidden]{display:none!important} 兜底，否则 hidden 不生效。
 *  3. 三档布局：
 *       ≥1100px 桌面   —— 内容限宽居中（1280px），头部/页签/工具条一行铺开，卡片横向一排
 *       641~1099 平板 —— 工具条改 2 列网格对齐，卡片操作按钮下沉到独立一行
 *       ≤640 手机      —— 页签横向滑动、筛选区折叠、按钮 ≥40px 触控、底部安全区
 *  4. 触控目标：桌面 ≥34px，平板 ≥38px，手机 ≥44px（Apple HIG / WCAG 2.5.5）。
 */

/* ================= 主题变量 =================
 * 挂在 :root 而不是 .gh —— 详情弹窗（.gh-modal）与提示气泡（.gh-toast）是 .gh 的兄弟节点、
 * 挂在 body 下，变量若只定义在 .gh 上会解析失败，导致弹窗 background 失效成透明、内容与列表糊在一起。 */
:root {
    /* 文字与容器 */
    --gh-card: var(--bg-primary, #fff);
    --gh-card-2: var(--bg-secondary, #16181c);
    --gh-line: var(--border-color, #2f3336);
    /* 控件边界单独一档：站点浅色主题的 --border-color 是 #eff3f4，
       透明底的按钮/输入框在浅色下会「隐形」，这里加一道可见轮廓 */
    --gh-line-2: color-mix(in srgb, var(--text-primary, #e7e9ea) 16%, transparent);
    --gh-fg: var(--text-primary, #e7e9ea);
    --gh-fg-2: var(--text-secondary, #71767b);
    --gh-accent: var(--accent, #1d9bf0);
    /* 语义色：绿=本期新增、琥珀=总榜殿堂、金=收藏 */
    --gh-green: #3fb950;
    --gh-gold: #e3a008;
    --gh-fav: #f0a429;
    /* 阴影：暗色用纯黑提亮，浅色用带色阴影 */
    --gh-shadow: 0 6px 22px rgba(0, 0, 0, .5);
    --gh-shadow-lg: 0 24px 60px rgba(0, 0, 0, .7);
    --gh-mask: rgba(0, 0, 0, .66);
    --gh-focus: 0 0 0 3px color-mix(in srgb, var(--gh-accent) 22%, transparent);
}
[data-theme="light"] {
    --gh-green: #1a7f37;
    --gh-gold: #9a6700;
    --gh-fav: #b45309;
    --gh-line-2: rgba(15, 20, 25, .16);
    --gh-shadow: 0 6px 20px rgba(15, 23, 42, .08);
    --gh-shadow-lg: 0 24px 60px rgba(15, 23, 42, .22);
    --gh-mask: rgba(15, 23, 42, .5);
}
body.page-github-hot-full .app { max-width: 100%; }
/* 页面容器 */
.gh {
    max-width: 100%;                 /* 桌面端满屏（保留左侧导航）：不写死像素宽度 */
    margin: 0 auto;
    padding: 22px 24px 64px;
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
}
body.page-github-hot-full .main-content { max-width: 100%; width: 100%; border-right: 0; }
.gh ::selection { background: color-mix(in srgb, var(--gh-accent) 30%, transparent); }

/* ---------- 头部 ---------- */
.gh-head { margin-bottom: 18px; }
.gh-head-top {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px 24px; flex-wrap: wrap; margin-bottom: 14px;
}
.gh-head-text { min-width: 0; flex: 1 1 420px; }
.gh-title {
    margin: 0 0 6px; font-size: 27px; line-height: 1.25;
    font-weight: 800; letter-spacing: -.02em; text-wrap: balance;
    color: var(--gh-fg);
}
.gh-sub {
    margin: 0; max-width: 44em;          /* 中文约 44 字/行，可读行长 */
    font-size: 14px; line-height: 1.7;
    color: var(--gh-fg-2); text-wrap: pretty;
}
.gh-head-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gh-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
    color: var(--gh-fg-2);
    background: var(--gh-card-2);
    border: 1px solid var(--gh-line-2);
    white-space: nowrap;
}
.gh-badge--time { font-variant-numeric: tabular-nums; }

/* ---------- 周期页签 ---------- */
.gh-tabs {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 14px; padding-bottom: 12px;
    border-bottom: 1px solid var(--gh-line-2);
    scrollbar-width: none;              /* 手机端横向滑动时隐藏滚动条 */
}
.gh-tabs::-webkit-scrollbar { display: none; }
.gh-tab {
    min-height: 36px; padding: 8px 18px; border-radius: 999px; cursor: pointer;
    font-size: 14px; font-weight: 600; font-family: inherit; line-height: 1.2;
    color: var(--gh-fg-2);
    background: transparent; border: 1px solid var(--gh-line-2);
    transition: color .15s, border-color .15s, background .15s, transform .1s;
}
.gh-tab:hover {
    color: var(--gh-accent); background: color-mix(in srgb, var(--gh-accent) 8%, transparent);
    border-color: color-mix(in srgb, var(--gh-accent) 45%, transparent);
}
.gh-tab.is-active {
    color: #fff; background: var(--gh-accent); border-color: var(--gh-accent);
    box-shadow: 0 2px 10px color-mix(in srgb, var(--gh-accent) 35%, transparent);
}
.gh-tab:focus-visible { outline: 2px solid var(--gh-accent); outline-offset: 2px; }
.gh-tabs-sep { width: 1px; height: 20px; background: var(--gh-line-2); margin: 0 4px; flex: 0 0 1px; }
.gh-tab--fav { display: inline-flex; align-items: center; gap: 6px; }
.gh-fav-count {
    min-width: 18px; padding: 0 5px; border-radius: 999px; font-size: 11px; line-height: 18px;
    text-align: center; font-variant-numeric: tabular-nums;
    background: var(--gh-card-2); color: var(--gh-fg-2);
}
.gh-tab.is-active .gh-fav-count { background: rgba(255, 255, 255, .25); color: #fff; }

/* ---------- 工具条 ---------- */
.gh-tools {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;
}
/* 桌面端用 display:contents 让筛选控件直接参与工具条排版，无需两套 DOM */
.gh-more { display: contents; }
.gh-filter-toggle { display: none; }
.gh-tools-spacer { flex: 1 1 auto; }
.gh-input, .gh-select {
    height: 38px; padding: 0 12px; box-sizing: border-box;
    font-size: 14px; font-family: inherit;
    color: var(--gh-fg);
    background: var(--gh-card);
    border: 1px solid var(--gh-line-2);
    border-radius: 10px;
    transition: border-color .15s, box-shadow .15s;
}
.gh-input { flex: 1 1 280px; min-width: 180px; }
.gh-select { flex: 0 1 auto; cursor: pointer; max-width: 190px; }
.gh-input::placeholder { color: color-mix(in srgb, var(--gh-fg-2) 78%, transparent); }
.gh-input:focus, .gh-select:focus {
    outline: none; border-color: var(--gh-accent); box-shadow: var(--gh-focus);
}
.gh-btn {
    height: 38px; padding: 0 16px; box-sizing: border-box; cursor: pointer;
    font-size: 14px; font-weight: 600; font-family: inherit;
    border-radius: 10px; border: 1px solid var(--gh-line-2);
    background: var(--gh-card); color: var(--gh-fg);
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s; transform .1s;
}
.gh-btn:hover { border-color: var(--gh-accent); color: var(--gh-accent); }
.gh-btn:focus-visible { outline: 2px solid var(--gh-accent); outline-offset: 2px; }
.gh-btn-primary { background: var(--gh-accent); border-color: var(--gh-accent); color: #fff; }
.gh-btn-primary:hover { background: var(--accent-hover, #1a8cd8); border-color: var(--accent-hover, #1a8cd8); color: #fff; }
.gh-btn-ghost { background: var(--gh-card-2); color: var(--gh-fg-2); }
.gh-btn-ghost:hover { background: color-mix(in srgb, var(--gh-accent) 8%, transparent); }
/* 有筛选生效时高亮「筛选」按钮（JS 加 is-on） */
.gh-filter-toggle.is-on { color: var(--gh-accent); border-color: var(--gh-accent); }

/* ---------- 状态条 ---------- */
.gh-state {
    font-size: 13px; color: var(--gh-fg-2);
    font-variant-numeric: tabular-nums; margin-bottom: 10px;
}
.gh-loading { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gh-fg-2); }
.gh-loading[hidden], .gh-empty[hidden], .gh-pager[hidden], .gh-mask[hidden],
.gh-select--archive[hidden], .gh-badge[hidden] { display: none !important; }
.gh-spin {
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--gh-line);
    border-top-color: var(--gh-accent);
    animation: ghSpin .7s linear infinite;
}
@keyframes ghSpin { to { transform: rotate(360deg); } }

/* ---------- 列表与卡片 ---------- */
/* contain 让每张卡片的布局/绘制互相隔离，长列表重排不再牵一发动全身 */
.gh-list { display: flex; flex-direction: column; gap: 10px; contain: layout style; }
.gh-card {
    display: flex; align-items: flex-start; gap: 14px;
    contain: layout style; content-visibility: auto; contain-intrinsic-size: auto 120px;
    padding: 14px 16px; box-sizing: border-box;
    background: var(--gh-card);
    border: 1px solid var(--gh-line-2);
    border-radius: 14px;
    transition: border-color .15s, box-shadow .15s;
}
.gh-card:hover {
    border-color: color-mix(in srgb, var(--gh-accent) 40%, transparent);
    box-shadow: var(--gh-shadow);
}
.gh-rank {
    flex: 0 0 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums;
    color: var(--gh-fg-2);
    background: var(--gh-card-2);
}
.gh-rank--1 { background: linear-gradient(135deg, #f7b955, #e08e0b); color: #fff; }
.gh-rank--2 { background: linear-gradient(135deg, #c3cdd6, #93a1ad); color: #fff; }
.gh-rank--3 { background: linear-gradient(135deg, #d9a06b, #b5773f); color: #fff; }

.gh-main { flex: 1 1 auto; min-width: 0; }
.gh-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gh-avatar {
    width: 24px; height: 24px; border-radius: 50%; flex: 0 0 24px;
    background: var(--gh-card-2); object-fit: cover;
}
.gh-name {
    font-size: 15px; font-weight: 700; color: var(--gh-fg);
    text-decoration: none; word-break: break-word;
}
.gh-name:hover { color: var(--gh-accent); text-decoration: underline; }
.gh-owner { font-weight: 500; color: var(--gh-fg-2); }
/* 绿 = 本期新增 Star（暗色 #3fb950 / 浅色 #1a7f37，均满足 4.5:1） */
.gh-period {
    padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
    color: var(--gh-green); background: color-mix(in srgb, var(--gh-green) 14%, transparent);
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* 琥珀 = 总榜（全平台总星标，与增量语义区分开） */
.gh-period--all {
    color: var(--gh-gold);
    background: color-mix(in srgb, var(--gh-gold) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--gh-gold) 35%, transparent);
}
.gh-desc {
    margin: 7px 0 0; font-size: 13.5px; line-height: 1.6;
    color: var(--gh-fg-2);
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; text-wrap: pretty;
}
.gh-desc--empty { color: color-mix(in srgb, var(--gh-fg-2) 62%, transparent); font-style: italic; }

.gh-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gh-topic {
    padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
    color: var(--gh-accent);
    background: color-mix(in srgb, var(--gh-accent) 12%, transparent);
    cursor: pointer; border: none; font-family: inherit;
    transition: background .15s;
}
.gh-topic:hover { background: color-mix(in srgb, var(--gh-accent) 22%, transparent); }
.gh-topic:focus-visible { outline: 2px solid var(--gh-accent); outline-offset: 2px; }

.gh-meta {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin-top: 9px; font-size: 12.5px; color: var(--gh-fg-2);
    font-variant-numeric: tabular-nums;
}
.gh-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.gh-lang { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.gh-dot { width: 9px; height: 9px; border-radius: 50%; background: #8b949e; flex: 0 0 9px; }

/* 操作区：桌面横排在卡片右上（不与正文抢宽度），平板/手机整体下沉到卡片底部一行 */
.gh-actions { display: flex; flex-direction: row; gap: 6px; flex: 0 0 auto; }
.gh-act {
    width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--gh-line-2);
    background: var(--gh-card); color: var(--gh-fg-2);
    font-size: 13px; font-family: inherit; line-height: 1;
    transition: color .15s, border-color .15s, background .15s; transform .1s;
}
.gh-act:hover { color: var(--gh-accent); border-color: var(--gh-accent); background: color-mix(in srgb, var(--gh-accent) 8%, transparent); }
.gh-act.is-on { color: var(--gh-fav); border-color: color-mix(in srgb, var(--gh-fav) 55%, transparent); background: color-mix(in srgb, var(--gh-fav) 12%, transparent); }
.gh-act:focus-visible { outline: 2px solid var(--gh-accent); outline-offset: 2px; }

/* ---------- 空态与分页 ---------- */
.gh-empty { padding: 56px 20px; text-align: center; }
.gh-empty-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--gh-fg); text-wrap: balance; }
.gh-empty-tip { margin: 0 auto; max-width: 34em; font-size: 13px; line-height: 1.7; color: var(--gh-fg-2); }

.gh-pager { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.gh-pg {
    min-width: 36px; height: 36px; padding: 0 12px; box-sizing: border-box; cursor: pointer;
    border-radius: 10px; border: 1px solid var(--gh-line-2);
    background: var(--gh-card); color: var(--gh-fg);
    font-size: 13px; font-family: inherit; font-variant-numeric: tabular-nums;
    transition: border-color .15s, color .15s; transform .1s;
}
.gh-pg:hover:not(:disabled) { border-color: var(--gh-accent); color: var(--gh-accent); }
.gh-pg.is-active { background: var(--gh-accent); border-color: var(--gh-accent); color: #fff; }
.gh-pg:disabled { opacity: .45; cursor: not-allowed; }
.gh-pg:focus-visible { outline: 2px solid var(--gh-accent); outline-offset: 2px; }
.gh-pg-dots { padding: 0 4px; color: var(--gh-fg-2); }

/* ---------- 详情弹窗 ---------- */
.gh-mask {
    position: fixed; inset: 0; z-index: 100000;
    display: flex; align-items: center; justify-content: center;
    padding: 24px; box-sizing: border-box;
    background: var(--gh-mask);
    backdrop-filter: blur(3px);
}
.gh-modal {
    position: relative; width: 100%; max-width: 620px; max-height: 88vh;
    overflow: auto; overscroll-behavior: contain;
    padding: 22px 24px; box-sizing: border-box;
    /* 双重保险：变量定义在 :root，这里仍写 fallback —— 弹窗是 body 下的节点，
       一旦变量链路出任何问题，也必须是不透明底而不是透明（否则内容与榜单糊在一起） */
    background: var(--gh-card, var(--bg-primary, #16181c));
    border: 1px solid var(--gh-line-2, rgba(127, 127, 127, .35));
    border-radius: 16px;
    box-shadow: var(--gh-shadow-lg, 0 24px 60px rgba(0, 0, 0, .7));
    isolation: isolate;               /* 弹窗内容永远压在下层之上 */
}
.gh-modal-close {
    position: absolute; top: 12px; right: 14px;
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--gh-line-2);
    background: transparent; color: var(--gh-fg-2);
    font-size: 18px; line-height: 1;
}
.gh-modal-close:hover { color: var(--gh-accent); border-color: var(--gh-accent); }
.gh-dt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding-right: 40px; }
.gh-dt-avatar { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: var(--gh-card-2); flex: 0 0 40px; }
.gh-dt-name { font-size: 17px; font-weight: 800; color: var(--gh-fg); word-break: break-word; text-wrap: balance; }
.gh-dt-owner { font-size: 13px; color: var(--gh-fg-2); }
.gh-dt-desc { margin: 0 0 14px; font-size: 14px; line-height: 1.75; color: var(--gh-fg-2); text-wrap: pretty; }
.gh-dt-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px; margin-bottom: 14px;
}
.gh-dt-cell {
    padding: 10px 12px; border-radius: 10px;
    background: var(--gh-card-2);
    border: 1px solid var(--gh-line-2);
}
.gh-dt-k { font-size: 11.5px; color: var(--gh-fg-2); margin-bottom: 3px; }
.gh-dt-v { font-size: 15px; font-weight: 700; color: var(--gh-fg); font-variant-numeric: tabular-nums; }
.gh-dt-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.gh-dt-link {
    padding: 7px 13px; border-radius: 9px; font-size: 13px; font-weight: 600;
    text-decoration: none; color: var(--gh-accent);
    border: 1px solid color-mix(in srgb, var(--gh-accent) 35%, transparent);
}
.gh-dt-link:hover { background: color-mix(in srgb, var(--gh-accent) 10%, transparent); }
/* 弹窗里用 button 承载「复制 clone」等动作，补齐按钮的默认样式 */
button.gh-dt-link { background: transparent; cursor: pointer; font-family: inherit; line-height: 1.4; }
/* 弹窗打开时锁住页面滚动（移动端尤其明显） */
body.gh-modal-open { overflow: hidden; }

/* ---------- 说明区 ---------- */
/* ---------- 说明区（可折叠，默认收起） ----------
 * 用原生 <details>：天然可键盘操作、可被读屏识别，不需要额外 JS 也能工作；
 * JS 只做一件事——把展开状态记到本机，用户下次回来不用重复展开。 */
.gh-about {
    margin-top: 30px; padding: 0; box-sizing: border-box;
    background: var(--gh-card-2);
    border: 1px solid var(--gh-line-2); border-radius: 14px;
    overflow: hidden;                 /* 配合圆角裁掉展开动画的溢出 */
}
.gh-about-title {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin: 0; padding: 13px 18px; cursor: pointer;
    font-size: 14px; font-weight: 700; color: var(--gh-fg);
    list-style: none;                 /* 去掉 Chrome 的三角标记 */
    -webkit-tap-highlight-color: transparent;
    transition: background .15s;
}
.gh-about-title::-webkit-details-marker { display: none; }
.gh-about-title::marker { content: ''; }
.gh-about-title:hover { background: color-mix(in srgb, var(--gh-accent) 7%, transparent); }
.gh-about-title:focus-visible { outline: 2px solid var(--gh-accent); outline-offset: -3px; }
/* 极简指示：一枚 14px 细线箭头，展开时旋转 180° */
.gh-about-caret {
    flex: 0 0 14px; color: var(--gh-fg-2);
    transition: transform .2s ease;
}
.gh-about[open] .gh-about-caret { transform: rotate(180deg); }
.gh-about[open] .gh-about-title { border-bottom: 1px solid var(--gh-line-2); }
.gh-about-body { padding: 16px 18px 18px; }
.gh-about-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px;
}
.gh-about-card {
    padding: 14px 16px; border-radius: 11px;
    background: var(--gh-card); border: 1px solid var(--gh-line-2);
}
.gh-about-card h3 { margin: 0 0 7px; font-size: 14px; font-weight: 700; color: var(--gh-fg); }
.gh-about-card p { margin: 0; font-size: 13px; line-height: 1.75; color: var(--gh-fg-2); text-wrap: pretty; }
.gh-about-note {
    margin: 14px 0 0; font-size: 12.5px; line-height: 1.8;
    color: var(--gh-fg-2);
}

/* ---------- 提示气泡 ---------- */
.gh-toast {
    position: fixed; left: 50%; bottom: calc(42px + env(safe-area-inset-bottom));
    transform: translateX(-50%); z-index: 120000;
    padding: 10px 18px; border-radius: 10px;
    background: rgba(17, 24, 39, .94); color: #fff; font-size: 13px; font-weight: 600;
    box-shadow: var(--gh-shadow-lg); pointer-events: none;
    max-width: min(90vw, 420px); text-align: center;
}
.gh-toast[hidden] { display: none !important; }

/* ================= 平板：641 ~ 1099px ================= */
@media (max-width: 1099px) {
    .gh { padding: 18px 18px 56px; }
    .gh-title { font-size: 24px; }
    /* 工具条改 2 列网格：控件数量多时不再参差换行；搜索框与搜索按钮同行 */
    .gh-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: stretch; }
    .gh-input { grid-column: 1; width: 100%; }
    .gh-btn-primary { grid-column: 2; width: 100%; }
    .gh-filter-toggle { display: none; }   /* 平板筛选区本来就是平铺的，不需要折叠按钮 */
    .gh-more { display: contents; }
    .gh-select, .gh-btn { width: 100%; max-width: none; height: 40px; }
    .gh-tools-spacer { display: none; }
    /* 卡片：操作按钮下沉到独立一行，正文拿到整行宽度 */
    .gh-card {
        display: grid; align-items: start;
        grid-template-columns: 34px minmax(0, 1fr);
        grid-template-areas: "rank main" "actions actions";
        gap: 12px 14px;
    }
    .gh-rank { grid-area: rank; }
    .gh-main { grid-area: main; }
    .gh-actions {
        grid-area: actions; flex-direction: row; justify-content: flex-end;
        border-top: 1px solid var(--gh-line-2); padding-top: 10px;
    }
    .gh-act { width: 38px; height: 38px; }
    .gh-about-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
}

/* ================= 手机：≤ 640px ================= */
@media (max-width: 640px) {
    .gh {
        padding: 14px 12px calc(52px + env(safe-area-inset-bottom));
    }
    .gh-head-top { flex-direction: column; align-items: stretch; gap: 10px; }
    /* ★必须重置 flex-basis：桌面端是 flex:1 1 420px（主轴=宽度），
       在 column 布局下主轴变成高度，不重置就会撑出 420px 的空白 */
    .gh-head-text { flex: 0 1 auto; }
    .gh-title { font-size: 21px; }
    .gh-sub { font-size: 13px; line-height: 1.7; }
    .gh-head-badges { gap: 6px; }
    .gh-badge { font-size: 11.5px; padding: 4px 10px; }

    /* 页签改为单行横向滑动，省掉两行折行占用的首屏高度 */
    .gh-tabs {
        flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
        scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
        margin-inline: -12px; padding: 0 12px 10px;
        scroll-padding-inline: 12px;
    }
    .gh-tab { flex: 0 0 auto; min-height: 40px; padding: 9px 15px; font-size: 13.5px; scroll-snap-align: start; }
    .gh-tabs-sep { height: 22px; }

    /* 工具条：搜索 + 搜索按钮 + 筛选按钮一行，其余收进可展开区 */
    .gh-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .gh-input { grid-column: 1 / -1; font-size: 16px; height: 44px; }   /* 16px 防 iOS 自动缩放 */
    .gh-btn-primary { grid-column: 1; }        /* 手机端「搜索 / 筛选」并排一行，不浪费高度 */
    .gh-btn, .gh-select { height: 44px; font-size: 16px; border-radius: 12px; }
    .gh-more { display: none; }
    /* 手机端展开区用 flex：下拉整行、动作按钮两两并排。
       DOM 里「重置」与「导出 CSV」之间夹着 spacer 与归档下拉，用 order 把两个动作按钮挪到一起，
       否则会出现三个半宽按钮各占一行、右侧全空。 */
    .gh-tools.is-open .gh-more {
        display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1;
        margin-top: 2px; padding-top: 10px; border-top: 1px solid var(--gh-line-2);
    }
    .gh-tools.is-open .gh-more > select { flex: 1 1 100%; order: 3; }   /* 文案长，必须整行不截断 */
    /* 展开区里的按钮只有「重置」「导出 CSV」两个，各占半行并排（用类而非 id，将来加按钮也不会错位） */
    .gh-tools.is-open .gh-more > .gh-btn { flex: 1 1 calc(50% - 4px); order: 1; }
    .gh-filter-toggle { display: block; }

    .gh-card {
        padding: 12px 13px; gap: 10px; border-radius: 12px;
        grid-template-columns: 30px minmax(0, 1fr);
    }
    .gh-rank { flex: 0 0 30px; width: 30px; height: 30px; font-size: 13px; }
    .gh-avatar { width: 22px; height: 22px; flex: 0 0 22px; }
    .gh-name { font-size: 14.5px; }
    .gh-desc { font-size: 13px; margin-top: 6px; }
    .gh-topics { gap: 5px; margin-top: 7px; }
    .gh-meta { gap: 10px; font-size: 12px; margin-top: 8px; }
    .gh-actions { gap: 8px; padding-top: 9px; }
    .gh-act { width: 44px; height: 44px; font-size: 14px; border-radius: 11px; }   /* 触控目标 ≥44px */
    .gh-act + .gh-act { margin-left: 0; }

    .gh-empty { padding: 40px 14px; }
    .gh-pager { gap: 8px; margin-top: 16px; }
    .gh-pg { min-width: 44px; height: 44px; font-size: 14px; border-radius: 12px; }
    /* 弹窗改成底部抽屉（原来只在 ≤767px 有，640px 以下会漏掉） */
    .gh-mask { padding: 0; align-items: flex-end; }
    .gh-modal {
        max-width: none; width: 100%; max-height: 92vh;
        border-radius: 16px 16px 0 0;
        padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    }
    .gh-dt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .gh-dt-link { padding: 10px 14px; text-align: center; flex: 1 1 40%; }
    .gh-about { margin-top: 22px; }
    .gh-about-title { padding: 12px 14px; }
    .gh-about-body { padding: 13px 14px 15px; }
    .gh-about-grid { grid-template-columns: 1fr; }
    .gh-toast { left: 12px; right: 12px; transform: none; max-width: none; }
}

/* 极窄屏（≤380px）：星标/元信息再收紧一档，避免每行只剩一个字 */
@media (max-width: 380px) {
    .gh-meta { gap: 8px; font-size: 11.5px; }
    .gh-period { font-size: 11px; padding: 2px 8px; }
    .gh-act { width: 40px; height: 40px; }
}

/* 横向滚动条在页签上隐藏，但键盘/读屏仍可聚焦 */
@media (hover: none) {
    .gh-tab:active { transform: scale(.97); }
    .gh-btn:active, .gh-act:active, .gh-pg:active { transform: scale(.97); }
}

/* ---------- 动效降级：尊重系统「减少动态效果」 ---------- */
@media (prefers-reduced-motion: reduce) {
    .gh *, .gh *::before, .gh *::after {
        animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important; scroll-behavior: auto !important;
    }
    .gh-spin { animation: ghSpin 1.6s linear infinite !important; }  /* 加载指示仍需可感知 */
}
