/* =========================================================
 * AI 工具导航 —— 样式表
 * 浅色为默认主题，深色通过 [data-theme="dark"] 切换
 * ========================================================= */

:root {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-soft: #eef0f4;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --brand: #3b5bfd;
  --brand-2: #7c4dff;
  --grad: linear-gradient(135deg, #3b5bfd 0%, #7c4dff 100%);
  --border: #e4e7ec;
  --shadow: 0 2px 10px rgba(31, 35, 41, 0.06);
  --shadow-hover: 0 8px 24px rgba(59, 91, 253, 0.16);
  --radius: 12px;
  --hot: #ff4d4f;
  --new: #00b96b;
}

[data-theme="dark"] {
  --bg: #121417;
  --bg-card: #1c1f24;
  --bg-soft: #26292f;
  --text: #e8eaed;
  --text-2: #a2a8b3;
  --text-3: #6f7681;
  --border: #2e3238;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 8px 24px rgba(59, 91, 253, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s, color 0.25s;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---------- 头部 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: center; gap: 28px; height: 60px; }

.logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; white-space: nowrap; }
.logo .logo-badge {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--grad); color: #fff;
  display: grid; place-items: center; font-size: 17px;
}
.logo em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a {
  padding: 6px 14px; border-radius: 8px;
  color: var(--text-2); font-size: 15px; transition: all 0.18s;
}
.main-nav a:hover, .main-nav a.active { color: var(--brand); background: var(--bg-soft); }

.header-actions { display: flex; align-items: center; gap: 10px; }

/* 搜索框 */
.search-box { position: relative; }
.search-box input {
  width: 240px; height: 38px; padding: 0 38px 0 14px;
  border: 1px solid var(--border); border-radius: 19px;
  background: var(--bg-soft); color: var(--text);
  font-size: 14px; outline: none; transition: all 0.2s;
}
.search-box input:focus { border-color: var(--brand); background: var(--bg-card); width: 300px; }
.search-box .search-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }

.search-result {
  position: absolute; top: 46px; left: 0; width: 360px; max-height: 420px; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-hover);
  display: none; z-index: 120;
}
.search-result.show { display: block; }
.search-result a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.search-result a:last-child { border-bottom: none; }
.search-result a:hover { background: var(--bg-soft); }
.search-result .r-name { font-weight: 600; font-size: 14px; white-space: nowrap; }
.search-result .r-desc { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result .r-cat { margin-left: auto; font-size: 12px; color: var(--brand); white-space: nowrap; }
.search-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: 14px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-size: 17px;
  background: var(--bg-soft); color: var(--text-2); transition: all 0.2s;
}
.icon-btn:hover { background: var(--grad); color: #fff; }

.menu-btn { display: none; }

/* ---------- Hero 横幅 ---------- */
.hero {
  background: var(--grad);
  padding: 44px 0 58px; color: #fff; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -80px;
  width: 320px; height: 320px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}
.hero h1 { font-size: 34px; font-weight: 800; letter-spacing: 1px; }
.hero p { margin-top: 10px; font-size: 15px; opacity: 0.85; }
.hero-stats { display: flex; gap: 36px; margin-top: 26px; }
.hero-stats b { display: block; font-size: 26px; }
.hero-stats span { font-size: 13px; opacity: 0.75; }

/* ---------- 通用区块 ---------- */
.section { margin: 40px 0; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: 21px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.section-head h2 .s-icon {
  width: 34px; height: 34px; border-radius: 9px; background: var(--bg-soft);
  display: grid; place-items: center; font-size: 17px;
}
.section-head .more { margin-left: auto; font-size: 13px; color: var(--brand); white-space: nowrap; }
.section-head .more:hover { text-decoration: underline; }

/* ---------- 资源位 ---------- */
.banner-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.banner-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  transition: all 0.2s;
}
.banner-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--brand); }
.banner-card .b-icon { font-size: 26px; line-height: 1; }
.banner-card b { font-size: 15px; display: block; margin-bottom: 4px; }
.banner-card p { font-size: 13px; color: var(--text-2); }
.banner-card .b-tag {
  margin-left: auto; flex-shrink: 0; font-size: 12px;
  background: var(--bg-soft); color: var(--brand);
  padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}

/* ---------- 工具卡片网格 ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tool-card {
  position: relative; display: block;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 16px 14px;
  transition: all 0.2s; overflow: hidden;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--brand); }
.tool-card .t-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tool-card .t-name { font-size: 15px; font-weight: 700; }
.tool-card .t-desc { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t-badge {
  font-size: 11px; padding: 1px 7px; border-radius: 9px; font-weight: 600; flex-shrink: 0;
}
.t-badge.hot { color: var(--hot); background: rgba(255, 77, 79, 0.1); }
.t-badge.new { color: var(--new); background: rgba(0, 185, 107, 0.1); }
.tool-card::after {
  content: "↗"; position: absolute; right: 14px; top: 14px;
  color: var(--text-3); opacity: 0; font-size: 14px; transition: 0.2s;
}
.tool-card:hover::after { opacity: 1; color: var(--brand); }

/* ---------- 分类区 ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab-btn {
  padding: 5px 14px; border-radius: 16px; font-size: 13px;
  background: var(--bg-soft); color: var(--text-2); transition: all 0.18s;
}
.tab-btn:hover { color: var(--brand); }
.tab-btn.active { background: var(--grad); color: #fff; }

/* 分类锚点滚动定位（避开 sticky 头） */
.category { scroll-margin-top: 80px; }

/* 懒加载占位动画 */
.section.loading .tool-grid { min-height: 200px; }
.skeleton {
  border-radius: var(--radius); background: var(--bg-soft);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* 渐入 */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.45s, transform 0.45s; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- 侧边快捷导航 ---------- */
side-nav, .side-nav {
  position: fixed; right: 16px; top: 50%; transform: translateY(-50%); z-index: 90;
  display: flex; flex-direction: column; gap: 4px;
}
.side-nav a {
  padding: 4px 10px; font-size: 12px; color: var(--text-3);
  border-radius: 6px; transition: 0.15s;
}
.side-nav a:hover, .side-nav a.active { color: var(--brand); background: var(--bg-card); box-shadow: var(--shadow); }

/* ---------- 回到顶部 ---------- */
.back-top {
  position: fixed; right: 16px; bottom: 24px; z-index: 90;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-2);
  display: grid; place-items: center; font-size: 16px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: 0.25s;
}
.back-top.show { opacity: 1; pointer-events: auto; }
.back-top:hover { background: var(--grad); color: #fff; }

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 56px; padding: 30px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-card); text-align: center;
}
.site-footer p { font-size: 13px; color: var(--text-3); }
.site-footer .foot-links { display: flex; justify-content: center; gap: 20px; margin-bottom: 10px; flex-wrap: wrap; }
.site-footer .foot-links a { font-size: 13px; color: var(--text-2); }
.site-footer .foot-links a:hover { color: var(--brand); }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .tool-grid { grid-template-columns: repeat(3, 1fr); }
  .banner-grid { grid-template-columns: repeat(2, 1fr); }
  .side-nav { display: none; }
}

@media (max-width: 768px) {
  .main-nav, .search-box { display: none; }
  .header-inner { justify-content: space-between; }
  .menu-btn { display: grid; }
  .hero h1 { font-size: 24px; }
  .hero-stats { gap: 20px; }
  .hero-stats b { font-size: 20px; }
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
  .banner-grid { grid-template-columns: 1fr; }
  .search-box input, .search-box input:focus { width: 100%; }
  .search-result { width: calc(100vw - 40px); }
}

/* 移动端抽屉导航 */
.mobile-nav {
  display: none; flex-direction: column; gap: 2px;
  padding: 10px 20px 16px; border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.mobile-nav.show { display: flex; }
.mobile-nav a { padding: 10px 4px; color: var(--text-2); border-bottom: 1px solid var(--border); }
.mobile-nav a:last-child { border-bottom: none; }
