/* ==========================================================================
   AI 工具导航 · 首页布局（左侧分类栏 + 右侧卡片网格）
   —— 独立手写 CSS：不依赖 a5.css（那份是参考站编译产物，原子类覆盖不全）
   断点：<720 单列 / ≥720 双列 / ≥1180 三列，侧栏 ≥1024 固定在左侧
   ========================================================================== */

/* ---------- 外框 ---------- */
/* ★ 必须 flex-start：否则 aside 被拉伸到与右栏等高，height > 视口 ⇒ position:sticky 失效（滚走后回不来） */
.nav-wrap { display: flex; flex-direction: column; gap: 20px; align-items: flex-start; }
.nav-main { flex: 1 1 auto; min-width: 0; width: 100%; }

/* ---------- 左侧分类栏 ---------- */
.cat-side { width: 100%; }
.cat-panel { background: #fff; border: 1px solid #f1f5f4; border-radius: 16px; box-shadow: 0 1px 3px rgba(15, 23, 42, .05); overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid #f6f8f7; font-size: 14px; font-weight: 700; color: #0f172a; }
.cat-head svg { width: 16px; height: 16px; color: #16a34a; flex: 0 0 auto; }
.cat-list { padding: 8px 0; max-height: 268px; overflow-y: auto; }
.cat-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 10px 16px; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 14px; color: #4b5563; text-align: left;
  border-right: 2px solid transparent; transition: background .15s, color .15s;
}
.cat-item > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item:hover { background: #f8faf9; color: #16a34a; }
.cat-item--active { background: #f0fdf4; color: #16a34a; font-weight: 600; border-right-color: #22c55e; }
.cat-count { font-size: 12px; color: #9ca3af; flex: 0 0 auto; }
.cat-item--active .cat-count { color: #22c55e; }

/* ---------- 右侧工具条 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.sort-tabs { display: flex; align-items: center; gap: 4px; background: #fff; border: 1px solid #f1f5f4; border-radius: 12px; padding: 4px; box-shadow: 0 1px 3px rgba(15, 23, 42, .05); }
.sort-tab { padding: 6px 16px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font: inherit; font-size: 14px; font-weight: 500; color: #6b7280; transition: background .15s, color .15s; }
.sort-tab:hover { color: #16a34a; }
.sort-tab--active { background: #16a34a; color: #fff; box-shadow: 0 1px 2px rgba(22, 163, 74, .35); }
.toolbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.result-info { color: #9ca3af; font-size: 12px; }
.pricing-select { padding: 6px 12px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; color: #374151; font: inherit; font-size: 13px; outline: none; }
.pricing-select:focus { border-color: #4ade80; }

/* ---------- 卡片网格 ---------- */
.tool-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.grid-empty { grid-column: 1 / -1; }

/* ---------- 卡片（两态：默认大图封面 / 悬停详情） ---------- */
.tool-card {
  display: flex; flex-direction: column; background: #fff; cursor: pointer; overflow: hidden;
  border: 1px solid #f1f5f4; border-radius: 16px;
  height: 340px;            /* ★ 固定高度：hover 时内部只在卡片内变化，绝不会撑动下面一行（防抖） */
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
  transition: box-shadow .2s, transform .2s;
}
.tool-card:hover { box-shadow: 0 12px 28px rgba(15, 23, 42, .12); transform: translateY(-2px); }

/* 封面（默认显示，悬停收起） */
.tc-cover {
  position: relative; flex: 0 0 auto; height: 170px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: height .28s ease, opacity .2s ease;
}
.tc-cover-letter { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 88px; font-weight: 800; color: rgba(255, 255, 255, .95); line-height: 1; user-select: none; }
/* ★ 封面① 官网截图：整块铺满（截到的是首页顶部，所以对齐上边） */
.tc-cover-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: top center; display: block;
}
/* ★ 封面② 工具图标（白底圆角牌，放大版）；无图标或加载失败时才显示字母 */
.tc-cover-icon {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 112px; height: 112px; border-radius: 26px; background: #fff; padding: 14px;
  object-fit: contain; box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
}
.tc-cover-badges { position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 6px; z-index: 2; }
.tc-chip { font-size: 11px; font-weight: 600; line-height: 1.4; padding: 3px 8px; border-radius: 6px; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.tc-chip--hot { color: #f97316; }
.tc-chip--price { color: #6b7280; }

/* 正文 */
.tc-main { flex: 1 1 auto; display: flex; flex-direction: column; padding: 14px 16px 0; min-height: 0; overflow: hidden; }
.tc-row { display: flex; align-items: flex-start; gap: 10px; }
.tc-avatar {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 16px;
  transition: border-radius .28s ease;
}
.tc-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tc-id { flex: 1 1 auto; min-width: 0; }
.tc-title { font-size: 15px; font-weight: 700; color: #0f172a; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-title a { color: inherit; text-decoration: none; }
.tc-title a:hover { color: #16a34a; }
.tc-cat { font-size: 12px; color: #9ca3af; margin-top: 2px; display: none; }
.tc-desc { font-size: 12.5px; color: #6b7280; line-height: 1.65; margin: 10px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fav-btn { flex: 0 0 auto; padding: 4px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; color: #d1d5db; line-height: 0; transition: background .15s, color .15s; }
.fav-btn:hover { background: #f9fafb; color: #f87171; }
.fav-btn--on { color: #ef4444; }

/* 悬停才出现的操作按钮（贴底，保证卡片高度不跳） */
.tc-actions { display: none; align-items: center; gap: 8px; margin-top: auto; padding: 12px 0 14px; }
.tc-btn { font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 9px; text-decoration: none; transition: all .15s; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.tc-btn--primary { background: #16a34a; color: #fff; }
.tc-btn--primary:hover { background: #15803d; }
.tc-btn--ghost { border: 1px solid #e5e7eb; color: #4b5563; background: #fff; }
.tc-btn--ghost:hover { border-color: #4ade80; color: #16a34a; }

/* 底部：分类标签 + 统计 */
.tc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-top: 1px solid transparent; transition: border-color .2s; }
.tc-tag { font-size: 12px; color: #6b7280; }
.tc-tag--cat { color: #2563eb; }
.tc-stat { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #9ca3af; }
.tc-stat-item { display: inline-flex; align-items: center; gap: 3px; }
.tc-ico { width: 13px; height: 13px; }

/* 悬停态：封面收起 → 头像变方、出现分类副标题与操作按钮、底部分隔线 */
.tool-card:hover .tc-cover { height: 0; }
.tool-card:hover .tc-avatar { border-radius: 12px; }
.tool-card:hover .tc-cat { display: block; }
.tool-card:hover .tc-actions { display: flex; }
.tool-card:hover .tc-foot { border-top-color: #f6f8f7; }

/* ---------- 响应式 ---------- */
@media (min-width: 720px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .nav-wrap { flex-direction: row; gap: 24px; }
  .cat-side { width: 216px; flex: 0 0 216px; position: sticky; top: 80px; }
  .cat-list { max-height: calc(100vh - 160px); overflow-y: auto; }
}
@media (min-width: 1180px) {
  .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* ★ 触屏设备没有 hover：按钮常显、分类副标题常显，封面矮一点（保证内容不被压） */
@media (hover: none) {
  .tc-cover { height: 130px; }
  .tc-actions { display: flex; }
  .tc-cat { display: block; }
  .tc-avatar { border-radius: 12px; }
  .tc-foot { border-top-color: #f6f8f7; }
}
