/* /tools/hacking 安全学习资源库 —— 设计令牌、三端排版、组件、无障碍 */
:root {
  --hk-bg: var(--bg-primary, #000);
  --hk-card: var(--bg-secondary, #16181c);
  --hk-card-2: var(--bg-elevated, #15202b);
  --hk-line: var(--border-color, #2f3336);
  --hk-line-2: color-mix(in srgb, var(--text-primary, #e7e9ea) 16%, transparent);
  --hk-fg: var(--text-primary, #e7e9ea);
  /* 深色次级文字原用站点 #71767b，对卡片仅约 3.9:1；提升到 ≥4.5:1 */
  --hk-fg-2: #8b98a5;
  /* 正文用确定色值，避免 color-mix 在不同浏览器/取值链下产生不可控的低对比结果 */
  --hk-fg-3: #c8cdd2;
  --hk-accent: var(--accent, #1d9bf0);
  /* 文字用亮蓝（对深色底 7:1），填充按钮用深一档蓝（白字 ≥4.5:1） */
  --hk-accent-ink: var(--hk-accent);
  --hk-accent-fill: #0b6fbd;
  --hk-accent-soft: color-mix(in srgb, var(--hk-accent) 14%, transparent);
  --hk-accent-line: color-mix(in srgb, var(--hk-accent) 42%, transparent);
  --hk-on-accent: #fff;
  --hk-sec: #35c88f;
  --hk-sec-soft: color-mix(in srgb, var(--hk-sec) 14%, transparent);
  --hk-gold: #f0b429;
  --hk-ok: #3fb950;
  --hk-warn: #e3a008;
  --hk-err: #f4212e;
  --hk-warn-soft: color-mix(in srgb, var(--hk-warn) 9%, transparent);
  --hk-zebra: rgba(127, 127, 127, .055);
  --hk-r-lg: 18px;
  --hk-r: 14px;
  --hk-r-md: 11px;
  --hk-r-sm: 9px;
  --hk-shadow: 0 4px 20px rgba(0, 0, 0, .22);
  --hk-shadow-sm: 0 1px 4px rgba(0, 0, 0, .14);
  --hk-mask: rgba(0, 0, 0, .62);
  --hk-sheet-mask: rgba(0, 0, 0, .38);
}
[data-theme="light"] {
  --hk-line-2: rgba(15, 20, 25, .15);
  --hk-card: #fff;
  --hk-card-2: #f2f5f6;
  --hk-fg-2: #5b6570;
  --hk-fg-3: #2b333b;
  /* 浅色下 #1d9bf0 作文字仅约 2.9:1；文字与填充按钮统一换成深一档蓝 */
  --hk-accent-ink: #0b6fbd;
  --hk-accent-fill: #0b6fbd;
  --hk-sec: #12805c;
  --hk-gold: #a56800;
  --hk-ok: #1a7f37;
  --hk-warn: #9a6700;
  --hk-zebra: rgba(15, 20, 25, .038);
  --hk-shadow: 0 4px 20px rgba(15, 20, 25, .10);
  --hk-shadow-sm: 0 1px 4px rgba(15, 20, 25, .08);
  --hk-mask: rgba(15, 20, 25, .42);
  --hk-sheet-mask: rgba(15, 20, 25, .28);
}

/* 电脑端满屏（保留左侧导航）；★overflow:visible 把滚动权交还 html，否则页内 sticky 全部失效 */
body.page-hacking-full { overflow: visible; }
body.page-hacking-full .app { max-width: 100%; }
body.page-hacking-full .main-content { max-width: 100%; width: 100%; border-right: 0; min-width: 0; }
body.page-hacking-full .page-container { max-width: 100%; }

.hk { max-width: 100%; margin: 0 auto; padding: 24px 28px calc(88px + env(safe-area-inset-bottom, 0px)); box-sizing: border-box; color: var(--hk-fg); font-size: 15px; }
.hk *, .hk *::before, .hk *::after { box-sizing: border-box; }
/* grid item 默认 min-width:auto，负边距/长文本会撑出横向溢出 */
.hk > *, .hk-search-row > *, .hk-filter-row > *, .hk-grid > *, .hk-path-grid > *, .hk-term-list > * { min-width: 0; }
.hk [hidden] { display: none !important; }
.hk button, .hk input, .hk select { font-family: inherit; }
.hk a { color: var(--hk-accent-ink); text-decoration: none; }
.hk a:hover { text-decoration: underline; }
.hk :focus-visible { outline: 2px solid var(--hk-accent-ink); outline-offset: 3px; }

/* ---------- hero 与统计仪表盘 ---------- */
.hk-hero { background: var(--hk-card); background: linear-gradient(135deg, var(--hk-accent-soft), var(--hk-card) 46%, var(--hk-sec-soft)); border: 1px solid var(--hk-line); border-radius: var(--hk-r-lg); padding: 24px 26px 20px; box-shadow: var(--hk-shadow); }
.hk-hero-top { display: flex; align-items: flex-start; gap: 18px; }
.hk-hero-ic { flex: 0 0 auto; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 30px; background: var(--hk-sec-soft); border: 1px solid var(--hk-accent-line); }
.hk-hero-t { min-width: 0; flex: 1 1 auto; }
.hk-title { margin: 0 0 7px; font-size: 27px; line-height: 1.25; letter-spacing: .3px; text-wrap: balance; }
.hk-sub { margin: 0; color: var(--hk-fg-2); line-height: 1.75; max-width: 68ch; font-size: 13.5px; text-wrap: pretty; }
.hk-hero-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.hk-tag { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--hk-card-2); border: 1px solid var(--hk-line-2); color: var(--hk-fg-3); white-space: nowrap; }
.hk-hero-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hk-badge { font-size: 12px; padding: 5px 11px; border-radius: 999px; background: var(--hk-card-2); border: 1px solid var(--hk-line-2); color: var(--hk-fg-2); white-space: nowrap; }
.hk-badge-link:hover { text-decoration: none; border-color: var(--hk-accent-line); color: var(--hk-accent-ink); }

/* 数字在上、标签在下：6 列在 1024px 也不挤；后两列是「我的」状态，弱底色分组 */
.hk-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 18px; border: 1px solid var(--hk-line); border-radius: var(--hk-r); overflow: hidden; background: var(--hk-bg); }
.hk-stat { min-width: 0; min-height: 66px; padding: 11px 16px; border-left: 1px solid var(--hk-line); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; }
.hk-stat:first-child { border-left: 0; }
.hk-stat b { font-size: 23px; line-height: 1.1; color: var(--hk-accent-ink); font-variant-numeric: tabular-nums; }
.hk-stat:nth-child(2) b { color: var(--hk-sec); }
.hk-stat:nth-child(5) b { color: var(--hk-gold); }
.hk-stat:nth-child(6) b { color: var(--hk-ok); }
.hk-stat:nth-child(n+5) { background: color-mix(in srgb, var(--hk-accent) 5%, transparent); }
.hk-stat em { font-style: normal; font-size: 12.5px; color: var(--hk-fg-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.hk-notice { margin: 14px 0 0; padding: 10px 13px; border-radius: var(--hk-r-sm); background: var(--hk-warn-soft); border: 1px solid color-mix(in srgb, var(--hk-warn) 32%, transparent); color: var(--hk-fg-3); font-size: 13px; line-height: 1.65; }

/* ---------- 页签 ---------- */
.hk-tabs { display: flex; gap: 6px; margin: 20px 0 14px; border-bottom: 1px solid var(--hk-line); overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.hk-tabs::-webkit-scrollbar { display: none; }
.hk-tab { flex: 0 0 auto; appearance: none; border: 0; background: transparent; color: var(--hk-fg-2); min-height: 44px; padding: 10px 18px 12px; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; scroll-snap-align: start; }
.hk-tab:hover { color: var(--hk-fg); }
.hk-tab.is-on { color: var(--hk-accent-ink); border-bottom-color: var(--hk-accent-fill); font-weight: 650; }

/* ---------- 工具条（吸顶） ---------- */
.hk-toolbar { position: sticky; top: 8px; z-index: 30; background: var(--hk-card); border: 1px solid var(--hk-line); border-radius: var(--hk-r); padding: 12px; box-shadow: var(--hk-shadow); }
.hk-search-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hk-search { position: relative; flex: 1 1 260px; min-width: 200px; display: flex; align-items: center; }
.hk-search-ic { position: absolute; left: 11px; color: var(--hk-fg-2); pointer-events: none; }
.hk-input { width: 100%; height: 40px; padding: 0 62px 0 36px; border: 1px solid var(--hk-line-2); border-radius: 10px; background: var(--hk-bg); color: var(--hk-fg); font-size: 14px; }
.hk-input::placeholder { color: var(--hk-fg-2); }
.hk-input:focus { border-color: var(--hk-accent-fill); box-shadow: 0 0 0 3px var(--hk-accent-soft); outline: none; }
.hk-input::-webkit-search-cancel-button { display: none; }
.hk-search-clear { position: absolute; right: 32px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--hk-card-2); color: var(--hk-fg-2); cursor: pointer; font-size: 17px; line-height: 1; }
.hk-kbd { position: absolute; right: 10px; font-size: 11px; color: var(--hk-fg-2); border: 1px solid var(--hk-line-2); border-radius: 5px; padding: 1px 6px; }
.hk-btn { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border: 1px solid var(--hk-line-2); border-radius: 10px; background: var(--hk-card-2); color: var(--hk-fg); font-size: 13px; cursor: pointer; white-space: nowrap; }
.hk-btn:hover { border-color: var(--hk-accent-line); color: var(--hk-accent-ink); }
.hk-btn[aria-pressed="true"] { background: var(--hk-accent-soft); border-color: var(--hk-accent-line); color: var(--hk-accent-ink); }
.hk-btn-pri { background: var(--hk-accent-fill); border-color: var(--hk-accent-fill); color: var(--hk-on-accent); }
.hk-btn-pri:hover { color: var(--hk-on-accent); filter: brightness(1.08); }
.hk-fav-num { color: var(--hk-gold); font-variant-numeric: tabular-nums; }
.hk-count { margin-left: auto; align-self: center; color: var(--hk-fg-2); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 筛选区改为确定性栅格：桌面 6 列一行、平板 3 列两行、手机 2 列三行 */
.hk-filter-toggle, .hk-filter-toggle-btn, .hk-filter-panel-head { display: none; }
.hk-filter-panel { display: block; }
.hk-filter-close { width: 40px; height: 40px; border: 1px solid var(--hk-line-2); border-radius: 9px; background: var(--hk-card-2); color: var(--hk-fg); font-size: 17px; cursor: pointer; }
.hk-filter-close:hover { border-color: var(--hk-accent-line); color: var(--hk-accent-ink); }
.hk-filter-row { display: grid; grid-template-columns: repeat(4, minmax(120px, 190px)) minmax(120px, 150px) auto; justify-content: space-between; gap: 10px; align-items: end; margin-top: 12px; }
.hk-fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 12px; color: var(--hk-fg-2); }
.hk-fld .hk-select { width: 100%; min-width: 0; max-width: 100%; }
.hk-fld-sm { max-width: none; }
.hk-select { height: 38px; padding: 0 9px; border: 1px solid var(--hk-line-2); border-radius: 9px; background: var(--hk-bg); color: var(--hk-fg); font-size: 13px; }
.hk-chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 11px; padding-bottom: 3px; scrollbar-width: thin; }
.hk-chip { flex: 0 0 auto; min-height: 32px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--hk-line-2); background: transparent; color: var(--hk-fg-2); font-size: 13px; cursor: pointer; white-space: nowrap; }
.hk-chip:hover { color: var(--hk-fg); border-color: var(--hk-accent-line); }
.hk-chip.is-on { background: var(--hk-accent-fill); border-color: var(--hk-accent-fill); color: var(--hk-on-accent); }
.hk-chip i { font-style: normal; opacity: .8; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* 细滚动条：长列表与横向 chips 都用同一套视觉 */
.hk-chips::-webkit-scrollbar, .hk-drawer-body::-webkit-scrollbar, .hk-filter-panel::-webkit-scrollbar { width: 8px; height: 8px; }
.hk-chips::-webkit-scrollbar-thumb, .hk-drawer-body::-webkit-scrollbar-thumb, .hk-filter-panel::-webkit-scrollbar-thumb { background: var(--hk-line-2); border-radius: 99px; }

/* ---------- 资源卡片 / 状态 ---------- */
.hk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 16px; }
.hk-card { display: flex; flex-direction: column; gap: 9px; min-width: 0; padding: 16px; background: var(--hk-card); border: 1px solid var(--hk-line); border-radius: var(--hk-r); cursor: pointer; transition: border-color .16s, transform .16s, box-shadow .16s; contain: layout style; }
.hk-card:hover { border-color: var(--hk-accent-line); transform: translateY(-1px); box-shadow: var(--hk-shadow); }
.hk-card.is-read { border-left: 3px solid var(--hk-sec); }
.hk-card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.hk-pill { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: var(--hk-card-2); border: 1px solid var(--hk-line-2); color: var(--hk-fg-2); white-space: nowrap; }
.hk-pill-dir { color: var(--hk-accent-ink); border-color: var(--hk-accent-line); background: var(--hk-accent-soft); }
.hk-pill-group { color: var(--hk-sec); border-color: color-mix(in srgb, var(--hk-sec) 40%, transparent); background: var(--hk-sec-soft); }
.hk-pill-lv { margin-left: auto; color: var(--hk-fg-2); letter-spacing: 1px; }
.hk-card-title { font-size: 16px; font-weight: 650; line-height: 1.4; margin: 0; overflow-wrap: anywhere; text-wrap: balance; }
.hk-card-en { font-size: 12.5px; color: var(--hk-fg-2); line-height: 1.45; overflow-wrap: anywhere; }
.hk-card-desc { font-size: 13.2px; color: var(--hk-fg-3); line-height: 1.7; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hk-card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.hk-mini { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--hk-bg); border: 1px solid var(--hk-line); color: var(--hk-fg-2); }
.hk-card-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--hk-line); }
.hk-act { appearance: none; border: 1px solid var(--hk-line-2); background: transparent; color: var(--hk-fg-2); border-radius: 8px; min-height: 32px; padding: 0 10px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.hk-act:hover { color: var(--hk-accent-ink); border-color: var(--hk-accent-line); }
.hk-act.is-fav { color: var(--hk-gold); border-color: color-mix(in srgb, var(--hk-gold) 45%, transparent); }
.hk-act.is-read { color: var(--hk-sec); border-color: color-mix(in srgb, var(--hk-sec) 45%, transparent); }
.hk-act-open { margin-left: auto; color: var(--hk-fg-2); text-decoration: none; font-size: 12.5px; }
.hk-act-open:hover { color: var(--hk-accent-ink); }
mark.hk-hl { background: color-mix(in srgb, var(--hk-gold) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

.hk-skel { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-top: 16px; }
.hk-skel-card { height: 200px; border-radius: var(--hk-r); border: 1px solid var(--hk-line); background: linear-gradient(100deg, var(--hk-card) 30%, var(--hk-card-2) 50%, var(--hk-card) 70%); background-size: 220% 100%; animation: hk-shine 1.4s linear infinite; }
@keyframes hk-shine { from { background-position: 140% 0; } to { background-position: -40% 0; } }
.hk-empty, .hk-error { text-align: center; padding: 56px 18px; border: 1px dashed var(--hk-line-2); border-radius: var(--hk-r); margin-top: 16px; background: var(--hk-card); }
.hk-empty-ic { font-size: 34px; opacity: .6; }
.hk-empty-t { color: var(--hk-fg-2); margin: 8px 0 14px; }
.hk-error { border-style: solid; border-color: color-mix(in srgb, var(--hk-err) 40%, transparent); }
.hk-error p { color: var(--hk-fg-3); line-height: 1.7; }
.hk-more-wrap { display: flex; justify-content: center; margin-top: 18px; }
.hk-more-wrap .hk-btn { min-width: 200px; min-height: 44px; }

/* ---------- 学习路径 / 术语 / 关于 ---------- */
.hk-pane-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 4px 0 16px; }
.hk-pane-head h2 { margin: 0 0 6px; font-size: 20px; text-wrap: balance; }
.hk-pane-head p { margin: 0; color: var(--hk-fg-2); font-size: 13.2px; line-height: 1.65; max-width: 62ch; }
.hk-progress { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--hk-fg-2); }
.hk-progress span { font-variant-numeric: tabular-nums; color: var(--hk-sec); font-weight: 650; }
.hk-progress em { font-style: normal; }
.hk-progress-bar { width: 150px; height: 8px; border-radius: 99px; background: var(--hk-card-2); overflow: hidden; }
.hk-progress-bar i { display: block; width: 0; height: 100%; border-radius: 99px; background: var(--hk-sec); transition: width .25s; }
.hk-path-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.hk-path { background: var(--hk-card); border: 1px solid var(--hk-line); border-radius: var(--hk-r); padding: 17px; display: flex; flex-direction: column; gap: 11px; contain: layout style; }
.hk-path-h { display: flex; align-items: center; gap: 10px; }
.hk-path-ic { width: 40px; height: 40px; display: grid; place-items: center; font-size: 21px; border-radius: 11px; background: var(--hk-accent-soft); border: 1px solid var(--hk-accent-line); }
.hk-path-h b { font-size: 16px; }
.hk-path-h em { display: block; font-style: normal; font-size: 12px; color: var(--hk-fg-2); }
.hk-path-desc { margin: 0; font-size: 13.2px; line-height: 1.7; color: var(--hk-fg-3); }
.hk-path-steps { list-style: none; counter-reset: hkstep; padding: 0; margin: 0; display: grid; gap: 7px; }
.hk-path-steps li { counter-increment: hkstep; display: flex; gap: 9px; font-size: 13px; color: var(--hk-fg-3); line-height: 1.6; }
.hk-path-steps li::before { content: counter(hkstep); flex: 0 0 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--hk-card-2); color: var(--hk-accent-ink); border: 1px solid var(--hk-line-2); }
.hk-path-items { display: flex; flex-wrap: wrap; gap: 5px; }
.hk-path-item { font-size: 12px; padding: 5px 9px; border-radius: 7px; border: 1px solid var(--hk-line-2); background: var(--hk-bg); color: var(--hk-fg-3); cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hk-path-item:hover { color: var(--hk-accent-ink); border-color: var(--hk-accent-line); }
.hk-path-foot { margin-top: auto; display: flex; gap: 8px; }

.hk-term-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hk-term-tools .hk-input { width: 270px; padding-left: 12px; padding-right: 12px; }
.hk-term-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 11px; }
.hk-term { background: var(--hk-card); border: 1px solid var(--hk-line); border-radius: var(--hk-r-sm); padding: 13px 15px; contain: layout style; }
.hk-term:nth-child(even) { background: color-mix(in srgb, var(--hk-fg) 3%, var(--hk-card)); }
.hk-term-h { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hk-term-en { font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; color: var(--hk-accent-ink); font-weight: 650; }
.hk-term-cn { font-size: 14px; font-weight: 650; }
.hk-term-dir { margin-left: auto; font-size: 11.5px; color: var(--hk-fg-2); }
.hk-term-def { margin: 8px 0 0; font-size: 13.2px; line-height: 1.7; color: var(--hk-fg-3); }

.hk-about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.hk-about-card { background: var(--hk-card); border: 1px solid var(--hk-line); border-radius: var(--hk-r); padding: 20px 22px; }
.hk-about-card h2 { margin: 0 0 11px; font-size: 17px; text-wrap: balance; }
.hk-about-card p { margin: 0 0 11px; font-size: 13.2px; line-height: 1.85; color: var(--hk-fg-3); max-width: 62ch; }
.hk-about-card p:last-child { margin-bottom: 0; }
.hk-about-warn { border-color: color-mix(in srgb, var(--hk-warn) 40%, transparent); background: color-mix(in srgb, var(--hk-warn) 6%, var(--hk-card)); }
.hk-faq-title { font-size: 18px; margin: 24px 0 13px; }
.hk-faq { display: grid; gap: 9px; }
.hk-faq details { background: var(--hk-card); border: 1px solid var(--hk-line); border-radius: var(--hk-r-sm); padding: 0 15px; }
.hk-faq details[open] { border-color: var(--hk-accent-line); background: var(--hk-accent-soft); }
.hk-faq summary { min-height: 44px; padding: 12px 0; cursor: pointer; font-size: 13.8px; font-weight: 650; list-style: none; }
.hk-faq summary::-webkit-details-marker { display: none; }
.hk-faq summary::after { content: '+'; float: right; color: var(--hk-accent-ink); font-weight: 400; }
.hk-faq details[open] summary::after { content: '\2212'; }
.hk-faq details p { margin: 0 0 15px; font-size: 13.2px; line-height: 1.85; color: var(--hk-fg-3); max-width: 70ch; }

/* ---------- 详情抽屉 / 提示 ---------- */
.hk-mask { position: fixed; inset: 0; z-index: 100000; background: var(--hk-mask); display: flex; justify-content: flex-end; align-items: stretch; }
.hk-drawer { width: min(540px, 100%); background: var(--hk-card); border-left: 1px solid var(--hk-line); box-shadow: -12px 0 40px rgba(0, 0, 0, .25); display: flex; flex-direction: column; }
.hk-drawer-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--hk-line); }
.hk-drawer-label { font-size: 12.5px; color: var(--hk-fg-2); }
.hk-drawer-close { width: 40px; height: 40px; border: 1px solid var(--hk-line-2); border-radius: 9px; background: var(--hk-card-2); color: var(--hk-fg); font-size: 22px; line-height: 1; cursor: pointer; }
.hk-drawer-close:hover { border-color: var(--hk-accent-line); color: var(--hk-accent-ink); }
.hk-drawer-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 20px 22px calc(34px + env(safe-area-inset-bottom, 0px)); scrollbar-width: thin; }
.hk-d-title { margin: 0 0 5px; font-size: 22px; line-height: 1.35; overflow-wrap: anywhere; text-wrap: balance; }
.hk-d-en { margin: 0 0 13px; font-size: 13px; color: var(--hk-fg-2); overflow-wrap: anywhere; }
.hk-d-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.hk-d-desc { font-size: 14px; line-height: 1.85; color: var(--hk-fg-3); margin: 0 0 13px; max-width: 66ch; }
.hk-d-en-desc { font-size: 12.8px; line-height: 1.75; color: var(--hk-fg-2); padding: 10px 12px; border-left: 3px solid var(--hk-line-2); background: var(--hk-bg); border-radius: 0 8px 8px 0; margin: 0 0 16px; }
.hk-d-sec { margin: 19px 0 0; }
.hk-d-sec h3 { font-size: 13.5px; margin: 0 0 10px; color: var(--hk-fg); display: flex; align-items: center; gap: 7px; }
.hk-d-sec h3::before { content: ''; width: 3px; height: 14px; border-radius: 3px; background: var(--hk-accent-fill); }
.hk-d-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.hk-d-points li { font-size: 13.2px; line-height: 1.75; color: var(--hk-fg-3); padding-left: 19px; position: relative; }
.hk-d-points li::before { content: '\2713'; position: absolute; left: 0; color: var(--hk-sec); }
.hk-d-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.hk-d-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
/* 「打开官网」是 <a>，浏览器不会像 <button> 那样默认居中文字 */
.hk-d-actions .hk-btn { min-width: 0; min-height: 44px; white-space: normal; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.hk-d-gh { margin-top: 17px; border: 1px solid var(--hk-line); border-radius: var(--hk-r-sm); padding: 13px 15px; background: var(--hk-bg); }
.hk-d-gh-t { font-size: 12.5px; color: var(--hk-fg-2); margin: 0 0 10px; }
.hk-d-gh-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.hk-d-gh-grid div { min-width: 0; }
.hk-d-gh-grid b { display: block; font-size: 14.5px; color: var(--hk-fg); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hk-d-gh-grid em { font-style: normal; font-size: 11.5px; color: var(--hk-fg-2); }
.hk-d-related { display: flex; flex-wrap: wrap; gap: 6px; }
.hk-d-note { font-size: 12.2px; color: var(--hk-fg-2); line-height: 1.75; margin-top: 19px; padding-top: 13px; border-top: 1px solid var(--hk-line); }

.hk-toast { position: fixed; z-index: 120000; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: min(88vw, 460px); padding: 11px 17px; border-radius: 10px; background: var(--hk-card-2); border: 1px solid var(--hk-accent-line); color: var(--hk-fg); box-shadow: var(--hk-shadow); font-size: 13.2px; text-align: center; }
.hk-toast.is-err { border-color: color-mix(in srgb, var(--hk-err) 55%, transparent); }
.hk-top { position: fixed; z-index: 90; right: 20px; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--hk-line-2); background: var(--hk-card-2); color: var(--hk-fg); font-size: 19px; cursor: pointer; box-shadow: var(--hk-shadow); }
.hk-top:hover { border-color: var(--hk-accent-line); color: var(--hk-accent-ink); }
body.page-hacking-full.hk-drawer-open { overflow: hidden; }

/* ---------- 桌面宽屏 ---------- */
@media (min-width: 1600px) {
  .hk { padding: 28px 40px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .hk-grid, .hk-skel { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
  .hk-path-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
  .hk-term-list { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
@media (min-width: 1800px) {
  .hk { padding-left: 52px; padding-right: 52px; }
  .hk-grid, .hk-skel { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
  .hk-hero { padding: 28px 32px 24px; }
}

/* ---------- 平板：筛选栅格降为 3 列，卡片略收窄 ---------- */
@media (max-width: 1199px) {
  .hk-filter-row { grid-template-columns: repeat(3, minmax(0, 1fr)); justify-content: stretch; }
  .hk-grid, .hk-skel { grid-template-columns: repeat(auto-fill, minmax(252px, 1fr)); }
  .hk-path-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .hk-term-list { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
  /* 平板上 hero 的简介过长会把首屏推到 900px 以下，简介折叠到 3 行；
     合规提示不参与截断：它是必须完整可读的授权警示 */
  .hk-sub { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
}
@media (max-width: 1100px) {
  .hk { padding: 20px 18px calc(76px + env(safe-area-inset-bottom, 0px)); }
  .hk-hero-side { flex-direction: row; flex-wrap: wrap; }
  .hk-hero { padding: 20px 20px 17px; }
}
/* 数字在上、标签在下的堆叠统计，直到 700px 仍能保持 6 列单行（比 3 列两行矮 70px） */

/* ---------- 手机：吸顶条压缩为「搜索 + 三按钮 + 筛选开关」，筛选区改为浮层 ---------- */
@media (max-width: 767px) {
  .hk { padding: 14px 12px calc(76px + env(safe-area-inset-bottom, 0px)); font-size: 14px; }
  body.page-hacking-full .main-content { overflow: visible; }
  .hk-input, .hk-select { font-size: 16px; }
  .hk-mask { align-items: flex-end; }
  .hk-toolbar { top: 8px; padding: 10px; }
  .hk-hero { padding: 15px 14px 13px; border-radius: 14px; }
  .hk-hero-top { flex-wrap: wrap; gap: 10px; }
  .hk-hero-ic { width: 44px; height: 44px; font-size: 23px; border-radius: 13px; }
  .hk-title { font-size: 21px; }
  .hk-sub { font-size: 12.8px; line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .hk-hero-tags { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-top: 10px; mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); }
  .hk-hero-tags::-webkit-scrollbar { display: none; }
  .hk-hero-side { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
  .hk-badge { font-size: 11px; padding: 4px 9px; }
  .hk-stats { margin-top: 12px; }
  .hk-stat { min-height: 58px; padding: 8px 10px; }
  .hk-stat b { font-size: 19px; }
  .hk-stat em { font-size: 12px; }
  /* 合规提示是关键信息：小屏不再按行数截断（实测 390px 宽约 3~4 行），只压缩字号与留白 */
  .hk-notice { margin-top: 10px; padding: 8px 10px; font-size: 12.2px; line-height: 1.55; }
  .hk-tabs { margin: 14px -12px 12px; padding: 0 12px; scroll-padding-inline: 12px; }
  .hk-tab { padding: 9px 13px 11px; font-size: 13.5px; min-height: 44px; }

  /* 搜索行：输入占整行，三个视图按钮等宽一行，筛选开关与结果数同行 */
  .hk-search-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .hk-search { grid-column: 1 / -1; flex: none; }
  .hk-input { height: 44px; padding-right: 44px; }
  .hk-select { height: 42px; }
  .hk-search-row .hk-btn { min-width: 0; min-height: 40px; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; }
  .hk-filter-toggle-btn { display: inline-flex; grid-column: 1 / 3; justify-content: center; align-items: center; min-height: 40px; }
  .hk-count { grid-column: 3; margin-left: 0; align-self: center; text-align: right; font-size: 12px; white-space: normal; }
  .hk-kbd { display: none; }
  .hk-search-clear { right: 8px; width: 34px; height: 34px; }

  /* 筛选浮层：展开时覆盖在内容之上，不再把吸顶条撑到 400px */
  /* 底部抽屉：始终在视口内，不随吸顶条的自然位置跑出屏幕；巨大 spread 阴影充当遮罩 */
  .hk-filter-panel {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 100001;
    padding: 20px 12px calc(16px + env(safe-area-inset-bottom, 0px));
    background: var(--hk-card); border: 1px solid var(--hk-line); border-bottom: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 0 0 100vmax var(--hk-sheet-mask), 0 -12px 40px rgba(0, 0, 0, .28);
    max-height: min(72dvh, 620px); overflow-y: auto; overscroll-behavior: contain;
  }
  .hk-filter-panel::before { content: ''; position: absolute; top: 7px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 99px; background: var(--hk-line-2); }
  .hk-filter-toggle:checked ~ .hk-filter-panel { display: block; }
  .hk-filter-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 11px; }
  .hk-filter-panel-head b { font-size: 14px; }
  .hk-filter-toggle:checked ~ .hk-search-row .hk-filter-toggle-btn { background: var(--hk-accent-soft); border-color: var(--hk-accent-line); color: var(--hk-accent-ink); }
  .hk-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 0; }
  .hk-fld { gap: 4px; }
  .hk-chips { margin-top: 10px; padding-bottom: 4px; mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); }
  .hk-chip { min-height: 40px; padding: 6px 13px; }

  .hk-grid, .hk-skel, .hk-path-grid, .hk-term-list, .hk-about-grid { grid-template-columns: minmax(0, 1fr); gap: 11px; }
  .hk-card { padding: 14px; }
  .hk-act, .hk-act-open { min-height: 40px; font-size: 12.5px; }
  .hk-btn { min-height: 42px; }
  .hk-btn[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--hk-accent-line); }
  .hk-more-wrap .hk-btn { min-height: 44px; }
  .hk-drawer-close { width: 44px; height: 44px; }
  .hk-term-tools .hk-input { width: 100%; }
  .hk-term-tools .hk-select { flex: 1 1 auto; }
  .hk-pane-head { gap: 10px; }
  .hk-pane-head h2 { font-size: 18px; }
  .hk-progress-bar { width: 110px; }
  .hk-drawer { width: 100%; max-height: min(88dvh, 760px); border-left: 0; border-top: 1px solid var(--hk-line); border-radius: 18px 18px 0 0; }
  .hk-drawer-head { position: relative; padding-top: 18px; }
  .hk-drawer-head::before { content: ''; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 99px; background: var(--hk-line-2); }
  .hk-drawer-body { padding: 16px 16px calc(30px + env(safe-area-inset-bottom, 0px)); }
  .hk-d-actions .hk-btn { min-height: 44px; }
  .hk-toast { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}

/* 600~767px 仍属平板宽度：卡片/路径/术语改成两列，避免 711px 宽的单列大卡 */
@media (min-width: 600px) and (max-width: 767px) {
  .hk-grid, .hk-skel, .hk-path-grid, .hk-term-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hk-about-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hk-search-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hk-search { grid-column: 1 / -1; }
  /* 四个操作按钮同排，结果数单独一行右对齐：搜索区从 3 行压到 2 行 */
  .hk-filter-toggle-btn { grid-column: auto; }
  .hk-count { grid-column: 1 / -1; text-align: right; }
}

/* 站点 .mobile-header 出现在 <=700px（高 53px），此断点才需要让位 */
@media (max-width: 700px) {
  .hk-toolbar { top: 53px; }
  .hk-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hk-stat:nth-child(3n+1) { border-left: 0; }
  .hk-stat:nth-child(n+4) { border-top: 1px solid var(--hk-line); }
}
@media (max-width: 560px) {
  .hk-term-list, .hk-path-grid, .hk-about-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .hk-hero-tags .hk-tag { font-size: 11px; padding: 3px 8px; }
  .hk-sub { -webkit-line-clamp: 2; }
  .hk-title { font-size: 19px; }
  .hk-pill { font-size: 10.5px; }
  .hk-d-gh-grid { grid-template-columns: minmax(0, 1fr); }
  .hk-d-title { font-size: 19px; }
  .hk-card-title { font-size: 15.5px; }
}
@media (max-width: 360px) {
  .hk-search-row .hk-btn > span:not(.hk-fav-num) { display: none; }
  .hk-search-row .hk-btn { font-size: 16px; }
  .hk-filter-toggle-btn > span { display: inline; }
  .hk-count { font-size: 11.5px; }
}

@media (hover: none) {
  .hk-card:hover { transform: none; }
  .hk-btn:hover, .hk-chip:hover, .hk-act:hover { border-color: var(--hk-line-2); color: var(--hk-fg); }
  .hk-btn-pri:hover { color: var(--hk-on-accent); filter: none; }
  /* 平板等触屏设备没有 hover 态，卡片操作按钮与方向 chip 的触控目标提到 40px */
  .hk-act { min-height: 40px; }
  .hk-chip { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .hk *, .hk *::before, .hk *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  .hk-toolbar, .hk-tabs, .hk-mask, .hk-toast, .hk-top, .hk-more-wrap, .hk-hero-side, .hk-hero-tags { display: none !important; }
  .hk-card { break-inside: avoid; }
  body.page-hacking-full .main-content { border: 0; }
  .hk-filter-panel { display: block !important; position: static; max-height: none; box-shadow: none; }
}
