/* =========================================================
   通用模板引擎（v1.6）
   一套 CSS 承载 56 套版式预设：侧栏位置 / 列数(1-8) / 卡片形态 /
   分类标题 / 头部样式 / 容器宽 / 圆角 / 小图标，全部由 body 上的
   data-* + CSS 变量驱动，配色变量由 PHP 内联输出到 <style>。

   版式基调：卡片只有名称（+ 域名），不放站点头像大图标；
   data-icon="tiny" 时名称前有一个 14px 小图标。
   列数：桌面 1-8（--col），1080→5，900→4，760→2-4，460→2；
   清单 / 行式两种形态在窄屏固定 1 列（避免一行只剩半个字）。
   ========================================================= */

.u {
  --uw: 1000px;
  --radius: 14px;
  --radius-sm: 8px;
  --col: 4;
  --col-lg: 5;
  --col-md: 4;
  --col-sm: 3;
  --col-xs: 2;
  --side-w: 250px;
}

.u-wrap { width: min(var(--uw), calc(100% - 40px)); margin: 0 auto; }

/* ---------------- 顶栏 ---------------- */
.u-bar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  border-bottom: 1px solid var(--border);
}
.u-bar-inner { display: flex; align-items: center; gap: 16px; height: 64px; }

.u-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.u-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: calc(var(--radius) * .6); font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--accent-strong, var(--accent)), var(--accent-2));
  box-shadow: var(--shadow-sm);
}
.u-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.u-brand-text strong { font-size: 15px; }
.u-brand-text small { font-size: 11px; color: var(--muted); }

.u-cats--bar { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.u-cats--bar::-webkit-scrollbar { display: none; }
.u-cats--bar .chip { white-space: nowrap; flex-shrink: 0; }

.u-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }

.u-search {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; min-width: 200px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2);
  transition: border-color .2s, box-shadow .2s;
}
.u-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.u-search svg { width: 15px; height: 15px; fill: var(--muted); flex-shrink: 0; }
.u-search input { flex: 1; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }

.u .btn.primary { box-shadow: 0 8px 18px -12px var(--accent); }
.u-friend-link { display: inline-flex; }

/* ---------------- 头部区 ---------------- */
.u-hero { padding: 40px 0 22px; }
.u-eyebrow { font-size: 11px; letter-spacing: .18em; color: var(--accent); font-weight: 600; margin: 0 0 8px; }
.u-hero h1 {
  margin: 0 0 10px; font-size: clamp(26px, 3.6vw, 40px); line-height: 1.16; letter-spacing: -.02em;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.u-lead { margin: 0 0 4px; color: var(--muted); font-size: 14.5px; max-width: 560px; }

/* split：左文右搜索 */
.u-hero--split .u-hero-split { display: grid; grid-template-columns: 1.05fr .95fr; gap: 32px; align-items: center; }
.u-hero-search--box {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 8px 6px 20px; height: 58px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.u-hero-search--box input { flex: 1; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); }

/* banner：整幅配色底 + 居中搜索 */
.u-hero--banner { padding: 0; }
.u-hero-banner {
  position: relative; display: grid; gap: 18px; justify-items: center; text-align: center;
  padding: 52px 24px 42px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(700px 300px at 18% -20%, var(--glow-1), transparent 70%),
    radial-gradient(600px 280px at 82% -30%, var(--glow-2), transparent 70%),
    linear-gradient(180deg, var(--accent-soft), transparent 90%);
}
.u-hero-banner .u-lead { max-width: 620px; }
.u-hero-search {
  display: flex; align-items: center; gap: 10px; width: min(520px, 100%);
  height: 48px; padding: 0 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md);
}
.u-hero-search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 15px; }
.u-kbd { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }

/* compact：一行说明 + 分类胶囊 */
.u-hero--compact { padding: 18px 0 6px; }
.u-hero-compact { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.u-hero-compact .u-eyebrow { margin: 0; letter-spacing: .08em; color: var(--muted); }
.u-jump { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- 布局：侧栏位置 ---------------- */
.u-layout { display: grid; gap: 24px; align-items: start; padding: 22px 0 34px; }
.u[data-side="left"] .u-layout { grid-template-columns: var(--side-w) minmax(0, 1fr); }
.u[data-side="right"] .u-layout { grid-template-columns: minmax(0, 1fr) var(--side-w); }
.u[data-side="right"] .u-side { order: 2; }
.u[data-side="none"] .u-layout,
.u[data-side="top"] .u-layout { grid-template-columns: minmax(0, 1fr); }

.u-side { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 14px; }
.u-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.u-panel-title { font-size: 12px; letter-spacing: .12em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.u-apply-text { margin: 0 0 10px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }

.u-main { min-width: 0; }

/* ---------------- 分类标题 ---------------- */
.u-cat { margin-bottom: 26px; scroll-margin-top: 90px; }
.u-cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.u-cat-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.u-cat-count { font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; }
.u-cat-line { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }
.u-cat-bar { width: 4px; height: 18px; border-radius: 2px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); flex-shrink: 0; }
.u-cat-no { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .04em; font-variant-numeric: tabular-nums; }

.u[data-head="plain"] .u-cat-line { display: none; }
.u[data-head="plain"] .u-cat-count { background: transparent; border-color: transparent; color: var(--muted); padding: 0; }
.u[data-head="pill"] .u-cat-head h2 {
  font-size: 14px; padding: 5px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.u[data-head="pill"] .u-cat-line { display: none; }
.u[data-head="bar"] .u-cat-head h2 { font-size: 17px; }
.u[data-head="num"] .u-cat-head h2 { font-size: 19px; }

/* ---------------- 名称网格 ---------------- */
.u-grid {
  display: grid;
  grid-template-columns: repeat(var(--col), minmax(0, 1fr));
  gap: 10px;
}

.u .u-card {
  min-width: 0;
  display: flex; gap: 7px; padding: 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s, border-color .18s, background .18s;
  position: relative; overflow: hidden;
}
.u .u-card::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0); transform-origin: left; transition: transform .25s;
}
.u .u-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 32%, var(--border)); }
.u .u-card:hover::after { transform: scaleX(1); }

/* 小图标（只有 data-icon="tiny" 的预设才出现，14px，跟在名称前面，不占主位） */
.u-fav {
  width: 14px; height: 14px; flex-shrink: 0; position: relative; overflow: hidden;
  border-radius: 3px; display: grid; place-items: center;
  background: color-mix(in srgb, hsl(var(--h) 68% 54%) 22%, var(--surface));
  color: hsl(var(--h) 62% 42%);
  font-size: 9px; font-weight: 700; line-height: 1;
}
.u-fav img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.u-fav img + i { opacity: 0; }

.u-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.u-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.u-row strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-go { width: 13px; height: 13px; fill: var(--muted); flex-shrink: 0; opacity: 0; transition: opacity .2s, transform .2s; }
.u-card:hover .u-go { opacity: 1; transform: translate(2px, -2px); fill: var(--accent); }
.u-desc { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.u-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-host { font-size: 11px; color: var(--muted); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 形态：名称宫格（竖排居中，无图标，靠名称+域名撑起来） */
.u[data-card="tile"] .u-card {
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 2px; padding: 10px 6px 8px; min-height: 54px;
}
.u[data-card="tile"] .u-card:has(.u-fav) { flex-direction: row; justify-content: center; gap: 6px; }
.u[data-card="tile"] .u-name { font-size: 13.5px; width: 100%; text-align: center; order: 2; }
.u[data-card="tile"] .u-host { font-size: 10.5px; order: 3; max-width: 100%; }
.u[data-icon="tiny"][data-card="tile"] .u-fav { order: 1; }
/* 带小图标的宫格：一行只有「图标 + 名称」，域名留给更宽的形态，避免 7-8 列时挤成省略号 */
.u[data-icon="tiny"][data-card="tile"] .u-host { display: none; }
.u[data-icon="tiny"][data-card="tile"] .u-name { flex: 0 1 auto; min-width: 0; }
/* 8 列密排时字号缩小，保证名称不被截断 */
.u[data-card="tile"] { --tile-fs: 13.5px; }

/* 形态：密排行（一行一个，名称左、域名右） */
.u[data-card="row"] .u-card { align-items: center; padding: 8px 12px; gap: 9px; }
.u[data-card="row"] .u-name { flex: 1; font-size: var(--fs-name, 13.5px); }
.u[data-card="row"] .u-host { margin-left: auto; }
.u[data-card="row"] .u-card::after { display: none; }
.u[data-card="row"] .u-grid { gap: 6px; }

/* 形态：清单（无框，细分割线） */
.u[data-card="list"] .u-grid { gap: 0; }
.u[data-card="list"] .u-card {
  background: transparent; border: 0; border-bottom: 1px solid var(--border);
  border-radius: 0; box-shadow: none; padding: 9px 2px;
  align-items: baseline; gap: 10px;
}
.u[data-card="list"] .u-card:hover { transform: none; background: var(--accent-soft); border-bottom-color: var(--border); box-shadow: none; }
.u[data-card="list"] .u-card::after { display: none; }
.u[data-card="list"] .u-name { font-size: 14.5px; }
.u[data-card="list"] .u-host { margin-left: auto; }

/* 形态：胶囊标签 */
.u[data-card="pill"] .u-grid { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.u[data-card="pill"] .u-card {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 999px; background: var(--surface);
  box-shadow: none; align-items: center; justify-content: center; text-align: center; gap: 6px;
}
.u[data-card="pill"] .u-card::after { display: none; }
.u[data-card="pill"] .u-name { font-size: 13px; }
.u[data-card="pill"] .u-card:hover { background: var(--accent-soft); border-color: var(--accent); transform: none; }

/* 形态：块卡（纯色块，名称居中） */
.u[data-card="block"] .u-card {
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 74px; padding: 10px 6px; gap: 3px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  box-shadow: none;
}
.u[data-card="block"] .u-name { font-size: 13px; }
.u[data-card="block"] .u-card::after { display: none; }
.u[data-card="block"] .u-card:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }

/* 卡片里的字号由 PHP 按列数写进 --fs-name（列越多字越小），不放 container 查询，
   否则胶囊/宫格这类 flex 自适应的形态会被 size containment 压成 0 宽 */
.u-name, .u-row strong { font-size: var(--fs-name, 14px); }
.u-desc { font-size: calc(var(--fs-name, 14px) - 1px); }

/* ---------------- 申请收录入口 / 页脚 ---------------- */
.u-apply-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 26px 0 4px; padding: 14px 16px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  font-size: 13px; color: var(--muted); background: var(--surface);
}
.u-apply-foot a { color: var(--accent); font-weight: 600; }

.u-footer { border-top: 1px solid var(--border); margin-top: 24px; padding: 24px 0 30px; background: var(--surface); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1180px) {
  .u { --side-w: 226px; }
}

@media (max-width: 1080px) {
  .u-grid { grid-template-columns: repeat(var(--col-lg), minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .u-grid { grid-template-columns: repeat(var(--col-md), minmax(0, 1fr)); }
  .u[data-side="left"] .u-layout,
  .u[data-side="right"] .u-layout { grid-template-columns: minmax(0, 1fr); }
  .u-side { position: static; order: 0; flex-direction: row; flex-wrap: wrap; }
  .u-side .u-panel { flex: 1 1 240px; }
  .u-side .cate-nav { flex-basis: 100%; }
  .u-side .cate-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .u-hero--split .u-hero-split { grid-template-columns: 1fr; gap: 20px; }
}

@media (max-width: 760px) {
  .u-wrap { width: calc(100% - 26px); }
  .u-bar-inner { height: 58px; gap: 10px; }
  .u-search { min-width: 0; flex: 1; }
  .u-brand-text small { display: none; }
  .u-friend-link { display: none; }
  .u-hero { padding: 26px 0 14px; }
  .u-hero-banner { padding: 32px 18px 26px; }
  /* 手机：2-4 列（由 PHP 按模板列数算好 --col-sm） */
  .u-grid { grid-template-columns: repeat(var(--col-sm), minmax(0, 1fr)); gap: 8px; }
  .u[data-card="tile"] .u-card { padding: 9px 5px 8px; min-height: 50px; }
  .u[data-card="tile"] .u-name { font-size: 13px; }
  .u[data-card="list"] .u-grid,
  .u[data-card="row"] .u-grid { grid-template-columns: 1fr; }
  .u-cats--bar { display: none; }
}

@media (max-width: 460px) {
  .u-search { display: none; }
  .u-grid { grid-template-columns: repeat(var(--col-xs), minmax(0, 1fr)); }
  .u[data-card="list"] .u-grid,
  .u[data-card="row"] .u-grid { grid-template-columns: 1fr; }
  .u[data-card="pill"] .u-grid { flex-wrap: wrap; }
  .u[data-card="pill"] .u-card { flex: 0 0 auto; }
  .u[data-card="tile"] .u-name { font-size: 12.5px; }
  .u-footer { padding: 20px 0 26px; }
}
/* 形态：文字墙 / 文字行（v1.7.19，纯文字无底无框，最紧凑） */
.u[data-card="text"] .u-grid { gap: 4px 12px; }
.u[data-card="text"] .u-card {
  background: transparent; border: 0; box-shadow: none; border-radius: 0;
  padding: 4px 2px; gap: 0; min-height: 0; min-width: 0; overflow: hidden; justify-content: flex-start;
}
.u[data-card="text"] .u-card::after { display: none; }
.u[data-card="text"] .u-card:hover { transform: none; box-shadow: none; background: transparent; border-color: transparent; }
.u[data-card="text"] .u-card:hover .u-name { color: var(--accent); }
.u[data-card="text"] .u-name { width: 100%; min-width: 0; }
.u[data-card="textrow"] .u-grid { gap: 0; }
.u[data-card="textrow"] .u-card {
  background: transparent; border: 0; box-shadow: none; border-radius: 0;
  padding: 7px 2px; border-bottom: 1px dashed var(--border); align-items: baseline; min-width: 0; overflow: hidden;
}
.u[data-card="textrow"] .u-card::after { display: none; }
.u[data-card="textrow"] .u-card:hover { transform: none; box-shadow: none; border-color: transparent; border-bottom-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--accent-soft); }
.u[data-card="textrow"] .u-name { flex: 1; min-width: 0; }
.u[data-card="textrow"] .u-host { margin-left: auto; }

/* ===== v1.7.21：友链区块（含分类间广告条）跟随当前模板形态与配色 =====
   原来友链卡片和广告条写死成一套「小方框 + 左边 3px 强调条」，和 t01–t62 的卡片形态对不上；
   这里统一读模板变量：--radius / --surface / --border / --shadow-sm / --accent-soft 都由配色决定，
   data-card 由模板决定，所以同一条广告在宫格模板是卡片、在文字模板是文字行、在清单模板是分隔行。
   ---- 广告条 ---- */
.u .ad-gap .ad-text {
  min-height: 54px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px;
}
.u .ad-gap .ad-text::before { border-radius: calc(var(--radius) * .4); }
.u .ad-gap .ad-link img { border-radius: var(--radius); }

/* 胶囊模板：广告条也做成胶囊 */
.u[data-card="pill"] .ad-gap .ad-text {
  min-height: 0; padding: 8px 16px; border-left-width: 1px; border-radius: 999px;
}
.u[data-card="pill"] .ad-gap .ad-text::before { border-radius: 999px; }

/* 纯文字模板：不留盒子，做成一行文字 + 虚线下边（和 t57–t62 的文字行同频） */
.u[data-card="text"] .ad-gap .ad-text,
.u[data-card="textrow"] .ad-gap .ad-text {
  min-height: 0; padding: 6px 2px;
  border: 0; border-bottom: 1px dashed var(--border); border-radius: 0; box-shadow: none;
  background: transparent; font-size: 13px;
}
.u[data-card="text"] .ad-gap .ad-text::before,
.u[data-card="textrow"] .ad-gap .ad-text::before {
  font-size: 10px; padding: 2px 4px; border-radius: 3px;
}

/* 清单 / 行式模板：整行分隔线，无卡片 */
.u[data-card="list"] .ad-gap .ad-text,
.u[data-card="row"] .ad-gap .ad-text {
  min-height: 0; padding: 9px 2px;
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none;
  background: transparent;
}

/* ---- 友链卡片 ---- */
.u .fh-item {
  padding: 11px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.u .fh-item:hover { box-shadow: var(--shadow-sm); }

/* 友链网格跟随模板列数（原来是 auto-fill 固定 148px 起） */
.u .fh-grid { grid-template-columns: repeat(var(--col), minmax(0, 1fr)); }
@media (max-width: 1180px) { .u .fh-grid { grid-template-columns: repeat(var(--col-lg), minmax(0, 1fr)); } }
@media (max-width: 980px) { .u .fh-grid { grid-template-columns: repeat(var(--col-md), minmax(0, 1fr)); } }
@media (max-width: 760px) { .u .fh-grid { grid-template-columns: repeat(var(--col-sm), minmax(0, 1fr)); } }
@media (max-width: 520px) { .u .fh-grid { grid-template-columns: repeat(var(--col-xs), minmax(0, 1fr)); } }

/* 文字模板：友链也只出名称（textrow 名称左、域名右） */
.u[data-card="text"] .fh-item,
.u[data-card="textrow"] .fh-item {
  padding: 5px 2px; gap: 0;
  border: 0; border-bottom: 1px dashed var(--border); border-radius: 0; box-shadow: none;
  background: transparent;
}
.u[data-card="text"] .fh-item:hover,
.u[data-card="textrow"] .fh-item:hover { transform: none; border-bottom-color: var(--accent); box-shadow: none; }
.u[data-card="text"] .fh-item .fh-host { display: none; }
.u[data-card="textrow"] .fh-item { flex-direction: row; align-items: baseline; gap: 8px; }
.u[data-card="textrow"] .fh-item .fh-host { margin-left: auto; }

/* 清单 / 行式模板：一条一条的分隔行 */
.u[data-card="list"] .fh-item,
.u[data-card="row"] .fh-item {
  padding: 9px 2px; gap: 0;
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none;
  background: transparent;
}
.u[data-card="list"] .fh-item:hover,
.u[data-card="row"] .fh-item:hover { transform: none; border-bottom-color: var(--accent); box-shadow: none; }
.u[data-card="list"] .fh-item,
.u[data-card="row"] .fh-item { flex-direction: row; align-items: baseline; gap: 8px; }
.u[data-card="list"] .fh-item .fh-host,
.u[data-card="row"] .fh-item .fh-host { margin-left: auto; }
/* ================= v1.7.24：卡片只显示名称 + 统一更矮 ================= */
/* 位置栏（所有分类卡片）一律不出网址、不出描述，只出名称；这里再兜一层，防旧缓存或以后被改回来 */
.u .u-card .u-host,
.u .u-card .u-desc,
.u .u-body { display: none !important; }

/* 所有形态统一向「小」看齐：基础内距收窄，不再靠 min-height 撑高 */
.u .u-card { padding: 7px 10px; gap: 6px; min-height: 0; align-items: center; }
.u[data-card="tile"] .u-card { min-height: 34px; padding: 6px 6px; }
.u[data-card="block"] .u-card { min-height: 36px; padding: 6px 6px; }
.u[data-card="card"] .u-card { min-height: 34px; padding: 7px 10px; }
.u[data-card="row"] .u-card { min-height: 30px; padding: 4px 11px; }
.u[data-card="list"] .u-card { min-height: 28px; padding: 4px 11px; }
.u[data-card="pill"] .u-card { min-height: 0; padding: 2px 10px; }
.u[data-card="text"] .u-card { min-height: 0; padding: 2px 2px; }
.u[data-card="textrow"] .u-card { min-height: 0; padding: 3px 2px; }

/* 友链区块同样只出名称、条目更矮 */
.u .fh-item { padding: 6px 9px; gap: 0; min-height: 0; }
.u .fh-item .fh-host { display: none; }
.u .fh-item .fh-name { font-size: 13px; }

/* 手机端继续压一档 */
@media (max-width: 760px) {
  .u[data-card="tile"] .u-card { min-height: 32px; padding: 5px 4px; }
  .u[data-card="block"] .u-card { min-height: 34px; padding: 5px 4px; }
  .u[data-card="row"] .u-card,
  .u[data-card="list"] .u-card { padding: 4px 9px; }
}
/* 卡片铺满网格列，避免只出名称后宽度参差 */
.u[data-card="tile"] .u-card,
.u[data-card="block"] .u-card,
.u[data-card="card"] .u-card { width: 100%; box-sizing: border-box; justify-self: stretch; }
/* ================= v1.7.25：自动友链位置与上方导航位置同款 ================= */
/* 宫格/卡片/特型①：与 .u-card 完全对齐（同高、同内距、同圆角、同阴影、名称居中、宽度铺满） */
.u .fh-grid { gap: 10px; }
.u .fh-item {
  min-height: 36px; padding: 6px; gap: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; width: 100%; box-sizing: border-box;
  border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--surface);
}
.u .fh-item .fh-name { font-size: 13px; font-weight: 600; }

/* 清单 / 行式：跟随导航行的高度与内距（分隔行、透明底） */
.u[data-card="list"] .fh-item,
.u[data-card="row"] .fh-item {
  min-height: 28px; padding: 4px 11px; flex-direction: row; align-items: center;
  justify-content: flex-start; text-align: left;
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; background: transparent;
}

/* 文字 / 文字行：同款细行，只有名称 */
.u[data-card="text"] .fh-item,
.u[data-card="textrow"] .fh-item {
  min-height: 0; padding: 2px 2px; flex-direction: column; align-items: flex-start;
  justify-content: flex-start; text-align: left;
  border: 0; border-bottom: 1px dashed var(--border); border-radius: 0; box-shadow: none; background: transparent;
}

/* 胶囊：与 pill 卡同高同圆角 */
.u[data-card="pill"] .fh-item {
  min-height: 0; padding: 2px 10px; border-radius: 999px;
  flex-direction: row; align-items: center; justify-content: center;
}

/* 手机端再压一档，与导航卡同步 */
@media (max-width: 760px) {
  .u .fh-item { min-height: 32px; padding: 5px 4px; }
  .u[data-card="list"] .fh-item,
  .u[data-card="row"] .fh-item { padding: 4px 9px; }
}
/* ================= v1.7.27：手机端列数与分类导航 ================= */
/* 1) 手机列数跟随模板（下限 3、上限 4），不再一律 2 列 */
@media (max-width: 760px) {
  /* 顶栏允许换行：品牌 + 搜索/按钮一行，分类胶囊一行（可横向滑动） */
  .u-wrap.u-bar-inner { flex-wrap: wrap; height: auto; min-height: 58px; padding: 8px 0; row-gap: 8px; }
  .u-brand { order: 1; }
  .perma { order: 2; }
  .u-tools { order: 3; margin-left: auto; }
  .u-cats--bar { display: flex; order: 9; flex: 1 1 100%; gap: 6px; padding: 0 0 2px; }
  .u-cats--bar .chip { font-size: 12px; padding: 4px 10px; }
}
@media (max-width: 460px) {
  /* 2) 侧栏在手机上仍然显示：分类表按两列排，不挤压 */
  .u-side { display: flex; }
  .u-side .u-panel { flex: 1 1 100%; }
  .u-side .cate-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .u-cats--bar { display: flex; }
}
/* v1.7.27 补充：顶部条模板在手机上顶栏已有分类胶囊，隐藏 hero 里重复的那排 */
@media (max-width: 760px) {
  .u[data-side="top"] .u-jump { display: none; }
}
/* ================= v1.7.28：手机端分类改为内容下方网格（不再置顶） ================= */
@media (max-width: 900px) {
  /* 侧栏不再排到内容上方，改为跟随在内容之后；分类表两/三列铺开 */
  .u-side { order: 2; position: static; display: block; margin-top: 22px; }
  .u-side .u-panel { width: 100%; margin-bottom: 12px; }
  .u-side .cate-nav { padding: 12px 14px; }
  .u-side .cate-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 14px; }
  .u-side .cate-list a { display: flex; align-items: center; justify-content: space-between; gap: 6px;
    padding: 7px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
}
@media (max-width: 460px) {
  .u-side .cate-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  /* 顶栏恢复单行，不再塞分类胶囊 */
  .u-wrap.u-bar-inner { flex-wrap: nowrap; height: 58px; padding: 0; }
  .u-cats--bar { display: none; }
  .u[data-side="top"] .u-jump { display: flex; }
}
/* ================= v1.7.29：手机端悬浮左侧栏抽屉 ================= */
.u-drawer, .u-drawer-tab, .u-drawer-mask { display: none; }

@media (max-width: 900px) {
  /* 侧栏面板在手机上彻底收起，只保留悬浮抽屉 */
  .u-side { display: none !important; }

  .u-drawer-tab {
    display: flex; position: fixed; left: 0; top: 50%; transform: translateY(-50%);
    writing-mode: vertical-rl; letter-spacing: 2px; text-orientation: upright;
    padding: 14px 7px; border: 0; cursor: pointer;
    background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
    border-radius: 0 12px 12px 0; z-index: 81;
    box-shadow: 2px 0 14px rgba(0, 0, 0, .18);
    transition: left .26s ease;
  }
  .u-drawer-tab:active { opacity: .9; }

  .u-drawer {
    display: block; position: fixed; left: 0; top: 0; bottom: 0; width: min(76vw, 300px);
    background: var(--surface); border-right: 1px solid var(--border);
    box-shadow: 10px 0 34px rgba(0, 0, 0, .16); z-index: 80;
    overflow-y: auto; padding: 16px 14px 22px;
    transform: translateX(-102%); transition: transform .26s ease;
  }
  .u-drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .u-drawer-head b { font-size: 15px; }
  .u-drawer-head span { font-size: 12px; color: var(--muted); }
  .u-drawer-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .u-drawer-item {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    padding: 10px 11px; min-height: 40px; font-size: 13px; font-weight: 600;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: inherit;
  }
  .u-drawer-item b { font-size: 11px; font-weight: 500; color: var(--muted); }
  .u-drawer-foot { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

  .u-drawer-mask {
    display: block; position: fixed; inset: 0; z-index: 79; background: rgba(0, 0, 0, .3);
    opacity: 0; pointer-events: none; transition: opacity .26s ease;
  }

  body.u-drawer-open .u-drawer { transform: none; }
  body.u-drawer-open .u-drawer-mask { opacity: 1; pointer-events: auto; }
  body.u-drawer-open .u-drawer-tab { left: min(76vw, 300px); }
}
@media (max-width: 460px) {
  .u-drawer-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* v1.7.30：抽屉收窄 + 分类单列 */
@media (max-width: 900px) {
  .u-drawer { width: min(60vw, 200px); padding: 12px 10px 16px; }
  .u-drawer-list { grid-template-columns: 1fr; gap: 6px; }
  .u-drawer-item { padding: 8px 9px; min-height: 32px; font-size: 12.5px; }
  .u-drawer-item b { font-size: 10.5px; }
  .u-drawer-head { margin-bottom: 10px; }
  .u-drawer-head b { font-size: 13.5px; }
  .u-drawer-head span { font-size: 11px; }
  .u-drawer-foot { margin-top: 10px; font-size: 11px; }
  body.u-drawer-open .u-drawer-tab { left: min(60vw, 200px); }
}
/* v1.7.31：抽屉再窄三分之一，高度自适应内容 */
@media (max-width: 900px) {
  .u-drawer {
    width: min(42vw, 136px); top: 96px; bottom: auto; height: auto;
    max-height: calc(100vh - 120px); padding: 10px 8px 12px;
    border-radius: 0 14px 14px 0;
  }
  .u-drawer-list { grid-template-columns: 1fr; gap: 5px; }
  .u-drawer-item { padding: 6px 8px; min-height: 28px; font-size: 12px; gap: 4px; }
  .u-drawer-item b { font-size: 10px; }
  .u-drawer-head { margin-bottom: 8px; }
  .u-drawer-head b { font-size: 12.5px; }
  .u-drawer-head span { display: none; }
  .u-drawer-foot { margin-top: 8px; font-size: 10px; }
  body.u-drawer-open .u-drawer-tab { left: min(42vw, 136px); }
}
/* v1.7.32：抽屉垂直居中 */
@media (max-width: 900px) {
  .u-drawer {
    top: 50%; bottom: auto; height: auto;
    max-height: calc(100vh - 40px);
    transform: translateY(-50%) translateX(-102%);
    border-radius: 0 14px 14px 0;
  }
  body.u-drawer-open .u-drawer { transform: translateY(-50%); }
}
/* v1.7.33：抽屉分类最多显示 10 项，超过 10 项列表内部上下滚动 */
@media (max-width: 900px) {
  .u-drawer-list {
    max-height: calc(10 * 28px + 9 * 5px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
  }
  .u-drawer { max-height: calc(100vh - 40px); }
}