/* ===== Variables ===== */
:root {
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-hover: #f0f2f5;
  --text: #1a1a2e;
  --text-sub: #666;
  --text-muted: #999;
  --border: #e8e8e8;
  --primary: #6c5ce7;
  --primary-light: #a29bfe;
  --primary-bg: rgba(108,92,231,0.08);
  --accent: #fd79a8;
  --success: #00b894;
  --warning: #fdcb6e;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0f0f23;
  --bg-card: #1a1a2e;
  --bg-hover: #25253e;
  --text: #e8e8e8;
  --text-sub: #aaa;
  --text-muted: #666;
  --border: #2a2a3e;
  --primary: #a29bfe;
  --primary-light: #6c5ce7;
  --primary-bg: rgba(162,155,254,0.1);
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

/* ===== Wallpaper ===== */
body.wallpaper-on {
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}
body.wallpaper-on::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  opacity: 0.85;
  z-index: -1;
}
body.wallpaper-on[data-theme="dark"]::before {
  background: rgba(15,15,35,0.88);
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; }

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

/* ===== Header ===== */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.logo-icon { font-size: 28px; }
.logo-img { width: 18px; height: 18px; border-radius: 3px; object-fit: contain; }
.search-box {
  flex: 1;
  max-width: 400px;
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  transition: var(--transition);
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.search-box input {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text);
  outline: none;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-btn {
  background: none;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
}
.nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-sub);
  transition: var(--transition);
}
.nav-link:hover { color: var(--primary); background: var(--primary-bg); }
.nav-link.active { color: var(--primary); background: var(--primary-bg); font-weight: 600; }
.theme-toggle {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* ===== Brand Banner ===== */
.brand-banner {
  margin: 16px 0 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  max-height: 80px;
}
.brand-banner img {
  width: 100%;
  max-height: 80px;
  display: block;
  border-radius: var(--radius);
  object-fit: cover;
  object-position: center;
}

/* ===== Stats ===== */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 24px 0;
}
.stat {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num { display: block; font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-sub); }

/* ===== Section ===== */
.section { display: none; padding: 20px 0 40px; }
.section.active { display: block; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0 16px;
}
.section-title h2 { font-size: 20px; font-weight: 700; }
.more-link { font-size: 14px; color: var(--text-sub); }
.more-link:hover { color: var(--primary); }

/* ===== Categories ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.cat-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.cat-card.active {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.cat-icon { font-size: 28px; display: block; margin-bottom: 6px; }
.cat-name { font-size: 13px; color: var(--text); font-weight: 500; }
.cat-count { font-size: 11px; color: var(--text-muted); }

/* ===== Tools Grid ===== */
.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);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}
.tool-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tool-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  overflow: hidden;
  gap: 2px;
}
.tool-logo-letter {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}
.tool-info { flex: 1; min-width: 0; }
.tool-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-origin {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
}
.tool-origin.china { background: #ffeaa7; color: #d63031; }
.tool-origin.overseas { background: #dfe6e9; color: #2d3436; }
.tool-desc {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tool-footer { display: flex; align-items: center; justify-content: space-between; }
.tool-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tool-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-sub);
}
.tool-pricing {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.tool-pricing.free { background: #00b89422; color: #00b894; }
.tool-pricing.freemium { background: #6c5ce722; color: #6c5ce7; }
.tool-pricing.paid { background: #fdcb6e22; color: #e17055; }
.tool-pricing.pay-per-use { background: #fd79a822; color: #fd79a8; }

/* ===== Filter Bar ===== */
.filter-bar { display: flex; gap: 8px; }
.filter-bar select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Rank List ===== */
.rank-list { display: flex; flex-direction: column; gap: 12px; }
.rank-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: var(--transition);
}
.rank-item:hover { box-shadow: var(--shadow); transform: translateX(4px); }
.rank-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.rank-num.top1 { background: #ffd700; color: #fff; }
.rank-num.top2 { background: #c0c0c0; color: #fff; }
.rank-num.top3 { background: #cd7f32; color: #fff; }
.rank-num.other { background: var(--bg); color: var(--text-sub); }
.rank-info { flex: 1; }
.rank-name { font-size: 15px; font-weight: 600; }
.rank-desc { font-size: 13px; color: var(--text-sub); }
.rank-hot {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

/* ===== Submit ===== */
.submit-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 600px;
}
.submit-form p { color: var(--text-sub); margin-bottom: 24px; font-size: 14px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.submit-result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #00b89422;
  color: var(--success);
  font-size: 14px;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-sub);
}
.modal-tool-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.modal-tool-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--primary-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: var(--primary);
}
.modal-tool-name { font-size: 18px; font-weight: 700; }
.modal-tool-origin { font-size: 12px; }
.modal-tool-desc { font-size: 14px; color: var(--text-sub); margin-bottom: 16px; line-height: 1.8; }
.modal-tool-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.modal-tool-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.modal-btn:hover { opacity: 0.9; color: #fff; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.footer-sub { margin-top: 6px; }

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(108,92,231,0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 90;
}
.back-to-top.show { opacity: 1; visibility: visible; }
.back-to-top:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(108,92,231,0.4); }

/* ===== Pricing Legend ===== */
.pricing-legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0 24px;
}
.pricing-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: default;
  transition: var(--transition);
}
.pricing-legend-item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}
.pricing-legend-icon {
  font-size: 24px;
  flex-shrink: 0;
}
.pricing-legend-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.pricing-legend-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* ===== Tool Detail Page ===== */
.tool-page { max-width: 700px; margin: 0 auto; padding: 20px 0; }
.tool-page-back {
  display: inline-block;
  color: var(--text-sub);
  font-size: 14px;
  margin-bottom: 20px;
  text-decoration: none;
}
.tool-page-back:hover { color: var(--primary); }
.tool-page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.tool-page-logo {
  width: 64px; height: 64px;
  border-radius: 14px;
  background: var(--primary-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: var(--primary);
  overflow: hidden; flex-shrink: 0;
}
.tool-page-logo img { width: 40px; height: 40px; }
.tool-page-name { font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.tool-page-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tool-page-desc { font-size: 16px; line-height: 1.8; color: var(--text-sub); margin-bottom: 16px; }
.tool-page-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 24px; }
.tool-page-actions { margin-bottom: 32px; }
.tool-page-related { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.tool-page-related h3 { font-size: 18px; margin-bottom: 16px; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 15px; }

/* ===== Loading Skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-card) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  height: 160px;
  border-radius: var(--radius);
}
.skeleton-stat {
  height: 80px;
  border-radius: var(--radius);
}

/* ===== Tool Card Favicon ===== */
.tool-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  margin-right: 2px;
  flex-shrink: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; height: auto; padding: 12px 0; gap: 10px; }
  .search-box { order: 3; max-width: 100%; width: 100%; }
  .nav { order: 2; }
  .stats-banner { grid-template-columns: repeat(2, 1fr); }
  .pricing-legend { grid-template-columns: repeat(2, 1fr); }
  .tools-grid { grid-template-columns: 1fr; }
  .categories-grid { grid-template-columns: repeat(3, 1fr); }
  .section-title { flex-direction: column; align-items: flex-start; gap: 8px; }
  .filter-bar { width: 100%; }
  .filter-bar select { flex: 1; }
  .modal-content { padding: 24px 20px; }
}
@media (max-width: 480px) {
  .categories-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-num { font-size: 24px; }
}
