/* ============================================================
   AI 工具导航站 - 自研样式
   深空 / 晨雾 双主题（CSS 变量实现明暗切换）
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --bg-nav: rgba(255, 255, 255, 0.82);
  --card-bg: #ffffff;
  --card-border: #e4e8f0;
  --text: #1f2733;
  --text-sub: #5b6472;
  --text-faint: #8a93a3;
  --accent: #3b6ef6;
  --accent-soft: rgba(59, 110, 246, 0.10);
  --accent-text: #2b5ce0;
  --shadow: 0 6px 22px rgba(31, 39, 51, 0.07);
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 1240px;
  --header-h: 64px;
}

[data-theme="dark"] {
  --bg: #0c1222;
  --bg-soft: #111a30;
  --bg-nav: rgba(12, 18, 34, 0.86);
  --card-bg: #16203a;
  --card-border: #26334f;
  --text: #e8ecf4;
  --text-sub: #a8b2c6;
  --text-faint: #6f7b93;
  --accent: #6c96ff;
  --accent-soft: rgba(108, 150, 255, 0.14);
  --accent-text: #8fb0ff;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  transition: background 0.25s ease, color 0.25s ease;
}

a { color: inherit; text-decoration: none; }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.brand img { height: 30px; width: auto; display: block; }
.brand .logo-dark { display: none; }
[data-theme="dark"] .brand .logo-dark { display: block; }
[data-theme="dark"] .brand .logo-light { display: none; }

.header-search {
  flex: 1;
  max-width: 480px;
  margin-left: auto;
  position: relative;
}

.header-search input {
  width: 100%;
  height: 38px;
  padding: 0 16px 0 38px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}

.header-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.header-search::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -8px;
  border: 2px solid var(--text-faint);
  border-radius: 50%;
}

.header-search::after {
  content: "";
  position: absolute;
  left: 25px;
  top: 50%;
  width: 6px;
  height: 2px;
  background: var(--text-faint);
  transform: rotate(45deg);
  transform-origin: left center;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid var(--card-border);
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-sub);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border 0.2s, color 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover { border-color: var(--accent); color: var(--accent-text); transform: rotate(18deg); }

/* ---------- 分类导航 ---------- */
.cat-nav {
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
}

.cat-nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.cat-nav-inner::-webkit-scrollbar { display: none; }

.cat-nav a {
  flex-shrink: 0;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text-sub);
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.cat-nav a:hover { color: var(--accent-text); }
.cat-nav a.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- 主区 ---------- */
.main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.hero {
  padding: 34px 0 26px;
  text-align: center;
}

.hero h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.hero p {
  margin-top: 10px;
  color: var(--text-sub);
  font-size: 15px;
}

.hero .stats {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  font-size: 13px;
  color: var(--text-sub);
}

.hero .stats b {
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  margin-right: 4px;
}

/* ---------- 分类区块 ---------- */
.cat-section { margin-top: 40px; scroll-margin-top: 119px; }

.cat-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--card-border);
}

.cat-head h2 {
  font-size: 21px;
  font-weight: 700;
}

.cat-head h2 span { color: var(--accent-text); margin-right: 8px; }

.cat-head .cat-count { font-size: 13px; color: var(--text-faint); }

/* ---------- 卡片网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(59, 110, 246, 0.14);
}

.card-thumb {
  width: 100%;
  height: 118px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  overflow: hidden;
  margin-bottom: 12px;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.card:hover .card-thumb img { transform: scale(1.04); }

.card-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-sub);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}

.card-cat {
  position: absolute;
  top: 26px;
  right: 26px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ---------- 搜索无结果 ---------- */
.empty-tip {
  display: none;
  text-align: center;
  padding: 60px 0;
  color: var(--text-faint);
  font-size: 15px;
}

body.searching .empty-tip.show { display: block; }

/* ---------- 详情页 ---------- */
.detail-wrap { max-width: 920px; margin: 0 auto; padding: 30px 20px 60px; }

.breadcrumb {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 20px;
}

.breadcrumb a:hover { color: var(--accent-text); }

.detail-hero {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}

.detail-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.detail-title h1 { font-size: 26px; font-weight: 800; }

.detail-title .badge {
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.detail-shot {
  margin-top: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  overflow: hidden;
  background: var(--bg-soft);
}

.detail-shot img {
  width: 100%;
  display: block;
}

.detail-actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s, transform 0.15s, border 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { transform: translateY(-2px); opacity: 0.92; }

.btn-ghost {
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text-sub);
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent-text); }

.detail-body {
  margin-top: 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}

.detail-body h2 {
  font-size: 18px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-body h2::before {
  content: "";
  width: 54px;
  height: 54px;
  flex: none;
  background-color: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2c.8 5.2 2.8 7.2 8 8-5.2.8-7.2 2.8-8 8-.8-5.2-2.8-7.2-8-8 5.2-.8 7.2-2.8 8-8z' fill='black'/%3E%3C/svg%3E") center / 39px 39px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2c.8 5.2 2.8 7.2 8 8-5.2.8-7.2 2.8-8 8-.8-5.2-2.8-7.2-8-8 5.2-.8 7.2-2.8 8-8z' fill='black'/%3E%3C/svg%3E") center / 39px 39px no-repeat;
}

.detail-body p { color: var(--text-sub); font-size: 14.5px; line-height: 1.8; }

.detail-body h3 {
  font-size: 15.5px;
  font-weight: 700;
  margin: 22px 0 10px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
}
.detail-body h3::before {
  content: "";
  width: 48px;
  height: 48px;
  flex: none;
  background-color: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2c.8 5.2 2.8 7.2 8 8-5.2.8-7.2 2.8-8 8-.8-5.2-2.8-7.2-8-8 5.2-.8 7.2-2.8 8-8z' fill='black'/%3E%3C/svg%3E") center / 33px 33px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2c.8 5.2 2.8 7.2 8 8-5.2.8-7.2 2.8-8 8-.8-5.2-2.8-7.2-8-8 5.2-.8 7.2-2.8 8-8z' fill='black'/%3E%3C/svg%3E") center / 33px 33px no-repeat;
}
.detail-body h3::after {
  content: "";
  flex: 1;
  height: 1px;
  margin-left: 8px;
  background: linear-gradient(90deg, var(--text-faint), transparent);
  opacity: .45;
}
.detail-body ul {
  margin: 0 0 8px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.detail-body li {
  color: var(--text-sub);
  font-size: 14.5px;
  line-height: 1.75;
}
.detail-body li strong { color: var(--text); font-weight: 700; }
.detail-body li b { color: var(--accent-text); font-weight: 600; }

/* ---------- 详情页相关推荐 ---------- */
.related-title { margin: 36px 0 16px; font-size: 18px; font-weight: 700; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--card-border);
  padding: 28px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

.site-footer .copyright {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-faint);
  opacity: 0.85;
}

/* ---------- 触控优化（无 hover 设备） ---------- */
@media (hover: none) {
  .card:hover {
    transform: none;
    border-color: var(--card-border);
    box-shadow: var(--shadow);
  }
  .card:active { transform: scale(0.97); border-color: var(--accent); }
  .card:hover .card-thumb img { transform: none; }
  .card:active .card-thumb img { transform: scale(1.03); }
  .btn-primary:hover { transform: none; opacity: 1; }
  .btn-primary:active { transform: translateY(-1px); opacity: 0.9; }
  .btn-ghost:hover { border-color: var(--card-border); color: var(--text-sub); }
  .btn-ghost:active { border-color: var(--accent); color: var(--accent-text); }
  .theme-toggle:hover { border-color: var(--card-border); color: var(--text-sub); transform: none; }
  .theme-toggle:active { border-color: var(--accent); color: var(--accent-text); transform: rotate(18deg); }
}

/* ---------- 响应式：平板 / 窄屏 ---------- */
@media (max-width: 768px) {
  .header-inner { padding: 0 16px; gap: 10px; }
  .brand { font-size: 17px; }
  .brand img { height: 26px; }
  .brand span { display: none; }
  .header-search { max-width: none; }
  .cat-nav-inner { padding: 0 12px; }
  .cat-nav a { padding: 11px 11px; font-size: 13.5px; }
  .main { padding: 20px 16px 48px; }
  .hero { padding: 24px 0 18px; }
  .hero h1 { font-size: 24px; }
  .hero p { font-size: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card { padding: 12px; }
  .card-thumb { height: 92px; }
  .card-name { font-size: 14px; }
  .card-desc { min-height: 36px; }
  .detail-wrap { padding: 20px 16px 48px; }
  .detail-hero { padding: 20px; }
  .detail-title h1 { font-size: 22px; }
  .detail-shot { margin-top: 16px; }
  .detail-body { padding: 20px; }
  .detail-body h2 { font-size: 17px; }
  .detail-body h2::before { width: 42px; height: 42px; -webkit-mask-size: 30px 30px; mask-size: 30px 30px; }
  .detail-body h3::before { width: 40px; height: 40px; -webkit-mask-size: 26px 26px; mask-size: 26px 26px; }
  .related-title { margin: 28px 0 14px; }
  .site-footer { padding: 22px 16px; }
}

/* ---------- 响应式：竖屏手机 ---------- */
@media (max-width: 480px) {
  .header-inner { padding: 0 12px; gap: 8px; }
  .brand { font-size: 16px; }
  .brand img { height: 24px; }
  .header-search input { height: 36px; padding: 0 12px 0 34px; font-size: 13.5px; }
  .header-search::before { left: 12px; }
  .header-search::after { left: 23px; }
  .theme-toggle { width: 34px; height: 34px; font-size: 15px; }
  .cat-nav-inner { padding: 0 8px; }
  .cat-nav a { padding: 10px 9px; font-size: 13px; }
  .main { padding: 16px 12px 40px; }
  .hero { padding: 18px 0 14px; }
  .hero h1 { font-size: 20px; }
  .hero p { font-size: 13.5px; }
  .hero .stats { gap: 6px 10px; font-size: 12.5px; }
  .hero .stats b { font-size: 14px; }
  .cat-section { margin-top: 30px; }
  .cat-head h2 { font-size: 18px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 10px; }
  .card-thumb { height: 80px; margin-bottom: 8px; }
  .card-name { font-size: 13px; }
  .card-desc { font-size: 12px; min-height: 34px; }
  .card-cat { top: 20px; right: 20px; font-size: 10px; padding: 1px 7px; }
  .detail-wrap { padding: 14px 12px 40px; }
  .breadcrumb { font-size: 12px; margin-bottom: 14px; }
  .detail-hero { padding: 16px; }
  .detail-title { gap: 10px; }
  .detail-title h1 { font-size: 19px; }
  .detail-title .badge { font-size: 11px; padding: 2px 10px; }
  .detail-actions { gap: 8px; }
  .btn { padding: 9px 16px; font-size: 13px; }
  .detail-body { padding: 16px; margin-top: 18px; }
  .detail-body h2 { font-size: 16px; }
  .detail-body h2::before { width: 36px; height: 36px; -webkit-mask-size: 26px 26px; mask-size: 26px 26px; }
  .detail-body h3 { font-size: 14.5px; margin: 18px 0 8px; }
  .detail-body h3::before { width: 34px; height: 34px; -webkit-mask-size: 22px 22px; mask-size: 22px 22px; }
  .detail-body p { font-size: 13.5px; }
  .detail-body ul { padding-left: 16px; gap: 5px; }
  .detail-body li { font-size: 13.5px; }
  .h-apd, .dsc-apd { margin: 8px 0; }
  .site-footer { padding: 18px 12px; font-size: 12px; }
}


/* ===== 广告位样式 ===== */
.h-apd,
.dsc-apd {
  margin: 10px 0;
  background: linear-gradient(135deg, #f6f7fb 0%, #eef0f6 100%);
  overflow: hidden;
  box-sizing: border-box;
}
.h-apd a,
.dsc-apd a {
  display: block;
}
.h-apd img,
.dsc-apd img {
  display: block;
  width: 100%;
  height: auto;
}

/* 搜索状态下隐藏首页广告位，避免搜索结果混入广告 */
body.searching .h-apd {
  display: none;
}

/* ===== 详情页右下角固定广告位 ===== */
.dsc-apd-fixed {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 240px;
  max-width: 240px;
  z-index: 999;
  background: linear-gradient(135deg, #f6f7fb 0%, #eef0f6 100%);
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.dsc-apd-fixed a {
  display: block;
}
.dsc-apd-fixed img {
  display: block;
  width: 100%;
  height: auto;
}
@media (max-width: 768px) {
  .dsc-apd-fixed {
    display: none;
  }
}
