/* ===== 基础重置 & 变量 ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0b0b0f;
  --bg-secondary: #111118;
  --bg-card: #16161f;
  --bg-card-hover: #1c1c28;
  --bg-elevated: #1e1e2d;
  --border-color: #2a2a3a;
  --border-hover: #3a3a50;
  --text-primary: #e8e8f0;
  --text-secondary: #9090a8;
  --text-muted: #606078;
  --accent-1: #6c5ce7;
  --accent-2: #a855f7;
  --accent-3: #3b82f6;
  --accent-gradient: linear-gradient(135deg, #6c5ce7, #a855f7, #3b82f6);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== 亮色主题 ===== */
[data-theme="light"] {
  --bg-primary: #f5f5f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0f5;
  --bg-elevated: #eaeaef;
  --border-color: #e0e0e8;
  --border-hover: #c0c0d0;
  --text-primary: #1a1a2e;
  --text-secondary: #5a5a72;
  --text-muted: #9090a8;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ===== 头部 ===== */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 28px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-img {
  height: 48px;
  width: auto;
  display: block;
}

.accent {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 640px;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  transition: all var(--transition);
  outline: none;
}

#searchInput:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

#searchInput::placeholder { color: var(--text-muted); }

.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent-1);
  background: var(--bg-card-hover);
}

/* ===== 语言选择器 ===== */
.lang-selector {
  position: relative;
  flex-shrink: 0;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.lang-btn:hover {
  border-color: var(--accent-1);
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.lang-current {
  font-weight: 500;
}

.lang-arrow {
  font-size: 10px;
  transition: transform 0.25s ease;
}

.lang-selector.active .lang-arrow {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: all 0.2s ease;
  z-index: 200;
  overflow: hidden;
}

.lang-selector.active .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.lang-option:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.lang-option.active {
  color: var(--accent-1);
  background: rgba(108, 92, 231, 0.08);
  font-weight: 600;
}

.lang-option.active::after {
  content: '✓';
  margin-left: auto;
  color: var(--accent-1);
}

/* ===== 广告位 ===== */
.ad-banner {
  padding: 16px 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.ad-footer {
  border-top: 1px solid var(--border-color);
  border-bottom: none;
}

.ad-placeholder {
  background: var(--bg-elevated);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition);
  cursor: pointer;
}

.ad-link {
  text-decoration: none;
  color: inherit;
}

.ad-placeholder:hover {
  border-color: var(--accent-2);
  background: var(--bg-card);
}

.ad-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.ad-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.ad-banner-inner {
  height: 80px;
}

.ad-banner-image-link {
  display: block;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: opacity var(--transition);
}

.ad-banner-image-link:hover {
  opacity: 0.92;
}

.ad-banner-image-link img {
  width: 100%;
  height: auto;
  display: block;
}

/* 侧边栏图片广告 */
.ad-sidebar-link {
  display: block;
  width: 100%;
  margin-bottom: 20px;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: opacity var(--transition);
  line-height: 0;
}

.ad-sidebar-link:hover {
  opacity: 0.92;
}

.ad-sidebar-link img {
  width: 100%;
  height: auto;
  display: block;
}

.ad-infeed {
  height: 80px;
  margin: 24px 0;
}

.ad-infeed-link {
  display: block;
  width: 100%;
  margin: 24px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: opacity var(--transition);
  line-height: 0;
}

.ad-infeed-link:hover {
  opacity: 0.92;
}

.ad-infeed-link img {
  width: 100%;
  height: auto;
  display: block;
}

.ad-sidebar {
  height: 200px;
  margin-bottom: 20px;
}

.ad-sidebar:nth-child(3) {
  height: 400px;
}

/* ===== 英雄区域 ===== */
.hero {
  padding: 48px 0 32px;
  text-align: center;
}

.hero-title {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* ===== 分类筛选 ===== */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
}

.filter-btn {
  padding: 10px 22px;
  border: 1px solid var(--border-color);
  border-radius: 100px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--accent-1);
  color: var(--text-primary);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.filter-btn.active {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
}

/* ===== 内容布局 ===== */
.content-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  padding: 8px 0 48px;
}

/* ===== 工具网格 ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ===== 工具卡片 ===== */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition);
}

.tool-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.tool-card:hover::before {
  opacity: 1;
}

.tool-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}

.tool-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

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

.tool-card-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-card-badge {
  font-size: 10px;
  background: var(--accent-gradient);
  color: #fff;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
}

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

.tool-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tool-card-tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 500;
}

.tool-card-tag.free {
  background: rgba(52, 211, 153, 0.12);
  color: #34d399;
}

.tool-card-tag.paid {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}

.tool-card-tag.freemium {
  background: rgba(96, 165, 250, 0.12);
  color: #60a5fa;
}

.tool-card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0;
  transform: translateX(-8px);
  transition: all var(--transition);
}

.tool-card:hover .tool-card-link {
  opacity: 1;
  transform: translateX(0);
}

/* ===== 加载更多 ===== */
.load-more {
  text-align: center;
  margin-top: 32px;
}

.load-more-btn {
  padding: 14px 40px;
  border: 1px solid var(--border-color);
  border-radius: 100px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.load-more-btn:hover {
  border-color: var(--accent-1);
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ===== 侧边栏 ===== */
.sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.hot-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hot-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  cursor: pointer;
}

.hot-list li:hover {
  background: var(--bg-card-hover);
}

.hot-rank {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-elevated);
  color: var(--text-muted);
  flex-shrink: 0;
}

.hot-rank.top-1 { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; }
.hot-rank.top-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; }
.hot-rank.top-3 { background: linear-gradient(135deg, #d97706, #92400e); color: #fff; }

.hot-name {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
}

.hot-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* 统计 */
.stats-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
}

.stats-item + .stats-item {
  border-top: 1px solid var(--border-color);
}

.stats-label {
  color: var(--text-secondary);
}

.stats-value {
  font-weight: 600;
  color: var(--accent-1);
}

/* ===== 页脚 ===== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 48px 0 24px;
  margin-top: 0;
}

.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}

.footer-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 12px;
  line-height: 1.7;
}

.footer-links h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.footer-links a {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 4px 0;
  transition: color var(--transition);
}

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

.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-bottom-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.beian-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.beian-link:hover {
  color: var(--accent-1);
}

.beian-icon {
  width: 16px;
  height: 16px;
  display: block;
}

/* ===== 弹窗 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 36px 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  animation: fadeInUp 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.modal-text {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.modal-close-btn {
  padding: 10px 36px;
  border: none;
  border-radius: 100px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity var(--transition);
}

.modal-close-btn:hover {
  opacity: 0.9;
}

/* ===== 动画 ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.tool-card {
  animation: fadeInUp 0.4s ease forwards;
}

.tool-card:nth-child(1) { animation-delay: 0.02s; }
.tool-card:nth-child(2) { animation-delay: 0.04s; }
.tool-card:nth-child(3) { animation-delay: 0.06s; }
.tool-card:nth-child(4) { animation-delay: 0.08s; }
.tool-card:nth-child(5) { animation-delay: 0.10s; }
.tool-card:nth-child(6) { animation-delay: 0.12s; }
.tool-card:nth-child(7) { animation-delay: 0.14s; }
.tool-card:nth-child(8) { animation-delay: 0.16s; }

/* ===== 空状态 ===== */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state-text {
  font-size: 16px;
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .content-layout {
    grid-template-columns: 1fr 260px;
  }
}

@media (max-width: 768px) {
  .content-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .ad-sidebar {
    height: 180px;
  }
  .ad-sidebar:nth-child(3) {
    height: 180px;
  }
  .hero-title {
    font-size: 30px;
  }
  .hero-subtitle {
    font-size: 15px;
  }
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
  .filter-btn {
    padding: 8px 16px;
    font-size: 13px;
  }
  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
  .logo-img {
    height: 40px;
  }
  .logo-text {
    font-size: 19px;
  }
}

/* ===== 手机端 (< 480px) ===== */
@media (max-width: 480px) {
  .header-inner {
    flex-direction: row;
    flex-wrap: wrap;
    height: auto;
    padding: 10px 0 8px;
    gap: 8px;
  }
  .header-inner .logo {
    width: auto;
  }
  .header-actions {
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }
  .search-box {
    min-width: 100%;
    order: 3;
    margin-top: 4px;
  }
  #searchInput {
    padding: 10px 14px 10px 38px;
    font-size: 14px;
  }
  .search-icon {
    left: 12px;
    font-size: 14px;
  }
  .logo-img {
    height: 32px;
  }
  .logo-text {
    font-size: 17px;
  }
  .lang-btn {
    padding: 0 8px;
    font-size: 12px;
    height: 38px;
  }
  .theme-toggle {
    width: 38px;
    height: 38px;
    font-size: 17px;
  }
  .lang-current {
    font-size: 12px;
  }
  .lang-option {
    padding: 10px 14px;
    font-size: 13px;
  }
  .sidebar {
    grid-template-columns: 1fr;
  }
  .ad-sidebar {
    height: 160px;
    margin-bottom: 12px;
  }
  .hero {
    padding: 24px 0 20px;
  }
  .hero-title {
    font-size: 24px;
  }
  .hero-subtitle {
    font-size: 14px;
    margin-bottom: 20px;
  }
  .category-filter {
    gap: 6px;
  }
  .filter-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  .tools-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .tool-card {
    padding: 16px;
  }
  .tool-card-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }
  .tool-card-name {
    font-size: 15px;
  }
  .tool-card-desc {
    font-size: 12px;
  }
  .tool-card-tags {
    margin-top: 8px;
  }
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .footer-links h4 {
    margin-bottom: 10px;
    font-size: 13px;
  }
  .footer-links a {
    font-size: 13px;
    padding: 3px 0;
  }
  .footer-bottom {
    padding-top: 16px;
    font-size: 11px;
  }
  .footer-bottom-inner {
    flex-direction: column;
    gap: 8px;
  }
  .beian-link {
    font-size: 11px;
  }
  .ad-banner-image-link img,
  .ad-infeed-link img {
    width: 100%;
    height: auto;
  }
  .ad-infeed-link {
    margin: 16px 0;
  }
  .ad-banner {
    padding: 10px 0;
  }
  .ad-banner-inner {
    height: 60px;
  }
  .load-more {
    margin-top: 20px;
  }
  .load-more-btn {
    padding: 12px 28px;
    font-size: 14px;
  }
  /* 弹窗手机适配 */
  .modal-content {
    padding: 28px 20px 24px;
  }
  .modal-icon {
    font-size: 40px;
  }
  .modal-text {
    font-size: 14px;
  }
  .modal-close-btn {
    padding: 10px 28px;
    font-size: 14px;
  }
  /* 空状态 */
  .empty-state {
    padding: 40px 16px;
  }
  .empty-state-icon {
    font-size: 36px;
  }
  .empty-state-text {
    font-size: 14px;
  }
}
