/* ==========================================================================
   海外工具导航（/tools）。页面由 worker 服务端渲染，这里只管样式。
   颜色一律走 ui.css 的 token，深色模式跟着变量自动翻转，不写第二遍。
   ========================================================================== */

/* ---- 顶部：搜索 + 统计 ---- */
.dir-search {
  position: relative;
  max-width: 560px;
  margin-top: 28px;
}
.dir-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 16px 20px 16px 50px;
  border: 2px solid var(--edge);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;   /* 16px 起步，iOS 聚焦时才不会自动放大页面 */
  font-weight: 600;
  box-shadow: var(--shadow-brutal);
}
.dir-search input:focus { outline: 0; border-color: var(--brand); }
.dir-search input::placeholder { color: var(--ink-4); font-weight: 500; }
.dir-search-ico { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); font-size: 18px; pointer-events: none; }

.dir-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 18px; font-size: 14px; color: var(--ink-3); font-weight: 600; }
.dir-stats b { color: var(--ink); font-weight: 900; }

/* ---- 主体：左侧分类 + 右侧网格 ---- */
.dir-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }

.dir-side {
  position: sticky;
  top: 84px;
  background: var(--surface);
  border: 2px solid var(--edge);
  border-radius: 16px;
  padding: 16px 10px;
  box-shadow: var(--shadow-brutal);
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.dir-side h3 { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 0 10px 10px; }
.dir-cat {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  border: 0; background: none; cursor: pointer;
  padding: 9px 10px; border-radius: 10px;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--ink-2);
}
.dir-cat span { font-size: 12px; font-weight: 700; color: var(--ink-4); }
.dir-cat:hover { background: var(--bg-2); }
.dir-cat.active { background: var(--brand); color: #fff; }
.dir-cat.active span { color: rgba(255,255,255,.8); }

.dir-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.dir-prices { display: flex; gap: 8px; flex-wrap: wrap; }
.dir-price {
  border: 2px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 8px 16px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 800;
}
.dir-price span { color: var(--ink-4); font-weight: 700; margin-left: 2px; }
.dir-price:hover { border-color: var(--ink); }
.dir-price.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.dir-price.active span { color: var(--bg); opacity: .7; }
.dir-count { font-size: 13px; color: var(--ink-3); font-weight: 700; }

/* ---- 工具卡片 ---- */
.dir-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .dir-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.tcard {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 2px solid var(--edge);
  border-radius: 16px;
  box-shadow: var(--shadow-brutal);
  transition: transform .15s, box-shadow .15s;
  min-width: 0;
}
.tcard:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-brutal-lg); }
.tcard[hidden] { display: none; }

.tcard-main { display: block; padding: 18px 18px 12px; color: inherit; text-decoration: none; flex: 1; }
.tcard-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tcard-icon {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 2px solid var(--line);
  font-size: 22px; line-height: 1;
}
.tcard-meta { min-width: 0; }
.tcard-name { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-cat { font-size: 12px; color: var(--ink-3); font-weight: 600; margin-top: 2px; }
.tcard-desc {
  font-size: 13px; line-height: 1.6; color: var(--ink-3);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.tcard-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 18px 14px; border-top: 1px dashed var(--line);
}
.tcard-links { display: flex; align-items: center; gap: 12px; }
.tcard-links a { font-size: 13px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.tcard-go { color: var(--ink); }
.tcard-go:hover { color: var(--brand-dark); }
.tcard-guide {
  color: var(--brand-dark);
  background: var(--brand-tint);
  padding: 4px 10px; border-radius: 999px;
}
.tcard-guide:hover { background: var(--brand); color: #fff; }

.ptag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.ptag-free     { background: var(--brand-tint); color: var(--brand-dark); }
.ptag-freemium { background: var(--info-bg);    color: var(--info-fg); }
.ptag-paid     { background: var(--warn-bg);    color: var(--warn-fg-2); }

.dir-empty { text-align: center; padding: 60px 20px; background: var(--bg-2); border-radius: 16px; }
.dir-empty[hidden] { display: none; }
.dir-empty h3 { font-size: 18px; margin-bottom: 6px; }
.dir-empty p { color: var(--ink-3); font-size: 14px; margin-bottom: 18px; }

/* ---- 窄屏：分类变成横向可滑的一行 ---- */
@media (max-width: 860px) {
  .dir-layout { grid-template-columns: 1fr; gap: 16px; }
  .dir-side {
    position: static; max-height: none;
    display: flex; gap: 6px; overflow-x: auto; padding: 10px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .dir-side::-webkit-scrollbar { display: none; }
  .dir-side h3 { display: none; }
  .dir-cat { width: auto; flex: none; white-space: nowrap; padding: 8px 12px; }
}
@media (max-width: 600px) {
  .dir-grid { grid-template-columns: 1fr; gap: 12px; }
  .dir-bar { flex-direction: column; align-items: flex-start; }
}
