/* ============================================================
   迹 · 免费资源 —— 复用 main.css 的变量 / 顶栏 / 页脚
   ============================================================ */

.wrap-wide { max-width: 1180px; }

.page-sub {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: .02em;
}

.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats-3 .stat b { font-family: var(--serif); font-size: 24px; letter-spacing: .02em; }

/* ---------- 两栏 ---------- */

.free-layout {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  gap: 38px;
  align-items: start;
}

.toc {
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-gutter: stable;
}
.toc::-webkit-scrollbar { width: 8px; height: 6px; }
.toc::-webkit-scrollbar-track { background: transparent; }
.toc::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--line-2) 72%, transparent);
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}
.toc::-webkit-scrollbar-thumb:hover,
.toc::-webkit-scrollbar-thumb:active {
  background: var(--accent);
  background-clip: content-box;
}
@supports (-moz-appearance: none) {
  .toc { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
}

.toc-h {
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px 10px;
}

.toc a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  transition: background .18s, color .18s;
}
.toc a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc a em { font-style: normal; font-size: 10.5px; opacity: .65; flex: 0 0 auto; }
.toc a:hover { color: var(--fg); background: var(--surface); }
.toc a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}
.toc a.active em { opacity: .9; }

/* ---------- 搜索 ---------- */

.free-search {
  position: sticky;
  top: 60px;
  z-index: 20;
  padding: 8px 0 14px;
  background: linear-gradient(var(--bg) 72%, transparent);
}
.free-search .ico {
  position: absolute;
  left: 15px;
  top: 21px;
  font-size: 14px;
  color: var(--muted);
  pointer-events: none;
}
.free-search input {
  width: 100%;
  padding: 11px 15px 11px 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--fg);
  font-size: 13.5px;
  font-family: var(--sans);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.free-search input::placeholder { color: var(--muted); }
.free-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 分类 ---------- */

.sec { margin: 0 0 40px; scroll-margin-top: 132px; }

.sec > h2 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .06em;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 4px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.sec > h2 .no {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--accent);
}
.sec > h2 .cnt {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .04em;
}

.items, .fi-sub { list-style: none; margin: 0; padding: 0; }

.fi {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background .18s, border-color .18s;
}
.fi:hover { background: var(--surface); border-color: var(--line); }

.fi-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color .18s;
}
a.fi-name:hover { color: var(--accent); }
.arw {
  font-size: 10px;
  color: var(--accent);
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity .18s, transform .18s;
}
a.fi-name:hover .arw { opacity: 1; transform: translateX(0); }

.fi-desc {
  margin: 3px 0 0;
  font-size: 13px;
  line-height: 1.7;
  font-weight: 500;
  color: var(--muted);
}

.fi-sub {
  margin: 4px 0 4px 10px;
  padding-left: 14px;
  border-left: 1px dashed var(--line-2);
}
.fi-sub > .fi { padding: 6px 10px; }
.fi-sub .fi-name { font-size: 13.2px; font-weight: 600; }
.fi-sub .fi-desc { font-size: 12.6px; }

mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 700;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
  font-size: 14px;
}
.empty b { color: var(--accent); }

/* ---------- 小屏 ---------- */

@media (max-width: 900px) {
  .free-layout { grid-template-columns: 1fr; gap: 18px; }
  .toc {
    position: static;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding: 0 0 10px;
  }
  .toc-h { display: none; }
  .toc a {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px;
    background: var(--surface);
  }
  .toc a em { display: none; }
  .free-search { top: 56px; }
  .sec { scroll-margin-top: 120px; }
}

@media (max-width: 640px) {
  .stats-3 { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: clamp(30px, 9vw, 40px); }
}

/* ---------- 嵌在资产页的上滑面板里 ---------- */

html.embed .wrap { padding-top: 16px; }
html.embed .page-head { margin-bottom: 20px; }
html.embed .page-title { font-size: clamp(24px, 4vw, 30px); }
html.embed .page-sub { font-size: 12.5px; margin-top: 6px; }
html.embed .stats { margin-bottom: 24px; }
html.embed .free-search { top: 0; }
html.embed .toc { top: 10px; max-height: calc(100vh - 28px); }
html.embed .sec { scroll-margin-top: 92px; }

/* ============================================================
   移动端：消除整页横向溢出
   —— grid/flex 子项默认 min-width:auto，目录里的 nowrap 胶囊会把
      整列撑宽，最终整页出现横向滚动。逐个压回 0 即可。
   ============================================================ */

.free-layout,
.free-body,
.toc,
.items,
.fi,
.fi-sub { min-width: 0; }

.fi-name,
.fi-desc,
.stat b,
.page-sub { overflow-wrap: anywhere; }

.toc { overscroll-behavior-x: contain; }

/* 面板内再兜一层：clip 不会像 hidden 那样产生滚动容器，粘性定位不受影响 */
html.embed { overflow-x: clip; }

@media (max-width: 640px) {
  .wrap,
  .wrap-wide { padding-left: 14px; padding-right: 14px; }
  .fi { padding: 8px 10px; }
  .fi-desc { font-size: 12.8px; line-height: 1.68; }
  .fi-sub { margin-left: 4px; padding-left: 10px; }
  .sec > h2 { font-size: 19px; }
  .stats-3 .stat b { font-size: 20px; }
  .free-search input { padding: 10px 13px 10px 35px; }
}

/* ============================================================
   移动端目录：横向胶囊 → 分类按钮 + 底部列表
   ============================================================ */

.free-search {
  display: flex;
  align-items: center;
  gap: 8px;
}
.free-search input { flex: 1 1 auto; min-width: 0; }

.cat-btn {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--fg);
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s, transform .15s;
}
.cat-btn:active { transform: scale(.96); border-color: var(--accent); color: var(--accent); }

@media (max-width: 900px) {
  .cat-btn { display: inline-flex; }
  .toc { display: none; }
}

/* ---------- 分类面板 ---------- */

.catmenu {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  background: rgba(17, 16, 19, .38);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.catmenu[hidden] { display: none; }

.catmenu-panel {
  width: 100%;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -18px 48px rgba(0, 0, 0, .25);
  animation: cat-up .32s cubic-bezier(.32, .72, 0, 1);
}
@keyframes cat-up { from { transform: translateY(100%); } }

.catmenu-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.catmenu-head span {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: .1em;
}
.catmenu-head button {
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.catmenu-head button:hover { color: var(--accent); border-color: var(--accent); }

.catmenu-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 8px 10px 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.catmenu-list::-webkit-scrollbar { width: 6px; }
.catmenu-list::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 99px;
}

.catmenu-list a {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--fg2);
}
.catmenu-list a span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catmenu-list a em { font-style: normal; font-size: 10.5px; color: var(--muted); flex: 0 0 auto; }
.catmenu-list a:active { background: var(--accent-soft); color: var(--accent); }

body.menu-open { overflow: hidden; }

@media (max-width: 420px) {
  .catmenu-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .catmenu-panel { animation: none; }
}
