/* 模板库样式 */

/* 顶部留白对齐内容页：模板库是「挑东西」的页，第一行不该顶着页头 */
.tpl-page { padding: 40px 0 72px; }

@media (max-width: 640px) {
  .tpl-page { padding: 22px 0 48px; }
}

.tpl-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.tpl-head h1 { margin-bottom: 6px; }
.tpl-sub { color: var(--ink-2); font-size: 14.5px; }

/* 筛选 */
.tpl-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 16px;
}

.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.chip {
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: #fff;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .14s;
}
.chip:hover { border-color: var(--ink-4); color: var(--ink); }
.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.tpl-count { font-size: 13px; color: var(--ink-3); margin-bottom: 14px; }

/* 网格 */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.tpl-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.tpl-item:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

/* 详情页入口（SEO 内链 + 用户「先看大图」的出口）。
   放在卡片底部单独一行：不能被 .tpl-info 的 flex 挤变形，也不能撑高卡片。 */
.tpl-detail {
  display: block;
  padding: 9px 14px 11px;
  border-top: 1px solid var(--line-2);
  font-size: 12.5px;
  color: var(--ink-3);
  text-decoration: none;
  letter-spacing: .02em;
}
.tpl-detail:hover { color: var(--accent-ink); text-decoration: none; }

.tpl-shot {
  height: 230px;
  /* 缩略图底衬：暖灰，和新的暖白页面统一（原来是冷灰 #eef2f6，改版后显得脏） */
  background: var(--line-2);
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
}
.tpl-shot .zj-paper {
  transform-origin: top left;
  box-shadow: none;
  pointer-events: none;
  /* 绝对定位，避免 flex 居中时 transform 前的 794px 宽度撑出滚动条 */
  position: absolute;
  left: 0;
  top: 0;
}

.tpl-info {
  padding: 11px 13px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tpl-info strong { font-size: 14px; font-weight: 500; }
.tpl-info .meta { font-size: 12px; color: var(--ink-3); }
.tpl-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* 弹窗预览 */
.pv-mask {
  position: fixed;
  inset: 0;
  background: rgba(23, 27, 33, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 300;
}
.pv-mask.show { opacity: 1; pointer-events: auto; }

.pv-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(1000px, 94vw);
  height: min(92vh, 980px);
  transform: translate(-50%, -46%);
  background: var(--bg);
  border-radius: var(--r-md);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 301;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pv-modal.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.pv-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.pv-modal-info { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.pv-modal-info strong { font-size: 15px; }
.pv-modal-info span { font-size: 12.5px; color: var(--ink-3); }
.pv-modal-actions { display: flex; gap: 8px; flex-shrink: 0; }

.pv-modal-stage {
  flex: 1;
  overflow: auto;
  padding: 22px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

@media (max-width: 1100px) {
  .tpl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .tpl-page { padding: 16px 0 40px; }
  .tpl-head { flex-direction: column; align-items: stretch; }
  .tpl-head .btn { align-self: flex-start; }
  .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tpl-shot { height: 168px; }
  .tpl-info strong { font-size: 13px; }
  .pv-modal { width: 100vw; height: 100vh; border-radius: 0; }
  .pv-modal-stage { padding: 12px; }
  .pv-modal-info span { display: none; }
}

/* ---------- 热度行：真实浏览/点赞 ----------
   放在名称行与详情链接之间；数字没过阈值时行内几乎为空（只有一个小 ♥）。 */
.tpl-stats {
  display: flex;
  align-items: center;
  justify-content: flex-end;   /* 只有爱心时靠右；浏览数出现时用 margin-left:auto 推左 */
  gap: 8px;
  min-height: 26px;
  padding: 0 14px;
  font-size: 12px;
  color: var(--ink-3);
}
.tpl-stats:empty { min-height: 0; padding: 0 14px; }
.tpl-views { letter-spacing: .2px; margin-right: auto; }
.tpl-like {
  appearance: none;
  border: 0;
  background: none;
  padding: 3px 6px;
  margin-right: -6px;
  font: inherit;
  color: #b3a394;
  cursor: pointer;
  border-radius: 6px;
  transition: color .15s, transform .15s;
}
.tpl-like:hover { color: #e2574c; background: rgba(226, 87, 76, .07); }
.tpl-like.on { color: #e2574c; }
.tpl-like:active { transform: scale(.92); }
.tpl-like:disabled { opacity: .5; cursor: default; }
