/* ==========================================================================
   小众技术工具库 · 样式表
   浅色主题 / 卡片网格 / 标签页 / 响应式
   ========================================================================== */

:root {
  --accent: #ff5a2c;
  --accent-2: #ff8a3d;
  --accent-soft: #fff1ea;
  --bg: #f5f6f9;
  --panel: #ffffff;
  --text: #1c2430;
  --text-2: #55606f;
  --text-3: #8b95a5;
  --line: #eceff4;
  --shadow-sm: 0 1px 2px rgba(22, 34, 51, .04);
  --shadow-md: 0 6px 18px rgba(22, 34, 51, .08);
  --radius: 12px;
  --radius-sm: 9px;
  --max: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------------------------------------------- 顶部栏 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .25s ease;
}

.site-header.is-stuck { box-shadow: var(--shadow-md); }

.header-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  height: 66px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff8a3d, #ff3d00);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(255, 90, 44, .28);
  letter-spacing: -1px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .3px;
}

.brand-slogan {
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: .2px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
}

.site-nav a {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background .18s ease, color .18s ease;
}

.site-nav a:hover { background: #f2f4f8; color: var(--text); }

.site-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  stroke: var(--text-3);
  fill: none;
  stroke-width: 2;
  pointer-events: none;
}

.search-box input {
  width: 236px;
  height: 38px;
  padding: 0 34px 0 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f8fa;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.search-box input::placeholder { color: #a6afbd; }

.search-box input:focus {
  background: #fff;
  border-color: #ffc4ad;
  box-shadow: 0 0 0 4px rgba(255, 90, 44, .1);
}

.search-clear {
  position: absolute;
  right: 8px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #e6e9ef;
  color: #6b7686;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: none;
  place-items: center;
}

.search-clear.is-visible { display: grid; }

/* ------------------------------------------------------- 分类快捷导航条 */
.catnav {
  position: sticky;
  top: 66px;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.catnav-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 46px;
  overflow-x: auto;
  scrollbar-width: none;
}

.catnav-inner::-webkit-scrollbar { display: none; }

.catnav-label {
  flex-shrink: 0;
  font-size: 12.5px;
  color: var(--text-3);
  margin-right: 4px;
}

.catnav a {
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  transition: background .16s ease, color .16s ease;
}

.catnav a:hover { background: #f2f4f8; color: var(--text); }

.catnav a.is-active {
  background: #1c2430;
  color: #fff;
}

/* ---------------------------------------------------------------- 内容区 */
main { padding: 22px 0 40px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 20px 22px;
  margin-bottom: 18px;
}

/* 区块标题 */
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: var(--accent-soft);
  flex-shrink: 0;
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .4px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-count {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-3);
  background: #f2f4f8;
  border-radius: 999px;
  padding: 1px 8px;
  letter-spacing: 0;
}

.panel-more {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--text-3);
  padding: 4px 10px;
  border-radius: 999px;
  transition: background .18s ease, color .18s ease;
}

.panel-more:hover { background: var(--accent-soft); color: var(--accent); }

/* 标签页 */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  border: 1px solid transparent;
  background: #f3f5f9;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .18s ease;
  font-family: inherit;
}

.tab:hover { background: #eaedf3; color: var(--text); }

.tab.is-active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(255, 90, 44, .25);
}

/* ---------------------------------------------------------------- 卡片 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
  gap: 10px;
}

.card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #ffd3c2;
  box-shadow: 0 8px 22px rgba(255, 90, 44, .12);
}

.card-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.2px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .06);
  overflow: hidden;
}

.card-body { min-width: 0; flex: 1; }

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-title span { overflow: hidden; text-overflow: ellipsis; }

.card-desc {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge-hot {
  flex-shrink: 0;
  font-size: 10px;
  line-height: 1;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #ff6a3d, #f0300a);
  padding: 2px 4px;
  border-radius: 4px;
  letter-spacing: 0;
}

/* 图标渐变（按名称哈希分配） */
.g0 { background: linear-gradient(135deg, #ff7a45, #f5222d); }
.g1 { background: linear-gradient(135deg, #4facfe, #096dd9); }
.g2 { background: linear-gradient(135deg, #43e97b, #189a55); }
.g3 { background: linear-gradient(135deg, #a18cd1, #6f42c1); }
.g4 { background: linear-gradient(135deg, #f6d365, #f5a623); }
.g5 { background: linear-gradient(135deg, #38f9d7, #0f9b8e); }
.g6 { background: linear-gradient(135deg, #ff9a9e, #e0457b); }
.g7 { background: linear-gradient(135deg, #7f8c9b, #3f4c5c); }

/* ------------------------------------------------------------ 推广区块 */
.panel-promo {
  background: linear-gradient(180deg, #fff8f4, #ffffff 62%);
  border-color: #ffe4d8;
}

.panel-promo .panel-icon {
  background: linear-gradient(135deg, #ffd7c6, #ffeae0);
}

.panel-promo .card {
  border-color: #f7e3d9;
}

.panel-cool {
  background: linear-gradient(180deg, #f5faff, #ffffff 62%);
  border-color: #dceaf7;
}

.panel-cool .panel-icon { background: #e4f0fb; }

/* ------------------------------------------------------------ 空状态 */
.empty {
  grid-column: 1 / -1;
  padding: 26px 0 22px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.empty::before {
  content: "";
  display: block;
  width: 26px;
  height: 26px;
  margin: 0 auto 8px;
  border: 2px solid #e2e7ef;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ 标签云 */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 12.5px;
  color: var(--text-2);
  background: #f3f5f9;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all .16s ease;
}

.tag:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ------------------------------------------------------------ 页脚 */
.site-footer {
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 30px 0 26px;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin-bottom: 12px;
}

.footer-links a { color: var(--text-2); }
.footer-links a:hover { color: var(--accent); }

.footer-note {
  max-width: 760px;
  margin: 0 auto 10px;
  line-height: 1.8;
  color: #9aa4b2;
}

.footer-copy { color: #a9b2bf; }

/* ------------------------------------------------------------ 返回顶部 */
.to-top {
  position: fixed;
  right: 26px;
  bottom: 28px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: var(--text-2);
  box-shadow: 0 6px 20px rgba(22, 34, 51, .14);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: all .22s ease;
  z-index: 70;
}

.to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.to-top:hover { color: var(--accent); }

/* ------------------------------------------------------------ 搜索结果态 */
.search-summary {
  display: none;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-2);
}

.search-summary.is-visible { display: flex; }

.search-summary b { color: var(--accent); }

.is-hidden { display: none !important; }

mark {
  background: #ffe7a8;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 1024px) {
  .search-box input { width: 180px; }
  .site-nav { display: none; }
}

@media (max-width: 760px) {
  .header-inner { height: 58px; gap: 12px; }
  .brand-slogan { display: none; }
  .brand-name { font-size: 16px; }
  .brand-mark { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }
  .search-box input { width: 100%; height: 34px; }
  .header-tools { flex: 1; }
  .search-box { flex: 1; }
  .catnav { top: 58px; }
  .catnav-inner { height: 42px; }
  .catnav-label { display: none; }
  main { padding: 16px 0 28px; }
  .panel { padding: 16px 14px 18px; border-radius: 10px; }
  .panel-title { font-size: 15.5px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
  .card { padding: 10px; gap: 8px; }
  .card-icon { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
  .card-desc { -webkit-line-clamp: 2; font-size: 11.5px; }
  .to-top { right: 14px; bottom: 18px; }
}
