:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-ring: rgba(37, 99, 235, 0.22);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 24px -4px rgba(15, 23, 42, 0.07), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 14px 32px -6px rgba(37, 99, 235, 0.14), 0 4px 10px -2px rgba(15, 23, 42, 0.06);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  position: relative;
}

.bg-decoration {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(680px circle at 14% 6%, rgba(37, 99, 235, 0.08), transparent 60%),
    radial-gradient(560px circle at 86% 10%, rgba(99, 102, 241, 0.07), transparent 60%),
    radial-gradient(500px circle at 50% 95%, rgba(14, 165, 233, 0.05), transparent 60%);
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(248, 250, 252, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
}

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

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

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-badge {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  box-shadow: var(--shadow-sm);
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
  line-height: 1.3;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.icon-pill-link,
.dev-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}

.icon-pill-link:hover,
.dev-link:hover {
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.dev-link .external-icon {
  opacity: 0.65;
}

/* Main */
.main-content {
  flex: 1;
  padding-top: 34px;
  padding-bottom: 48px;
}

/* Hero */
.hero {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 28px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid rgba(37, 99, 235, 0.18);
  margin-bottom: 14px;
}

.hero-title {
  margin: 0 0 12px;
  font-size: clamp(1.65rem, 3.2vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.22;
  color: var(--text);
}

.hero-subtitle {
  margin: 0 auto 24px;
  max-width: 640px;
  font-size: 0.98rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* Search + Category Filter */
.filter-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.search-box {
  position: relative;
  width: 100%;
  max-width: 580px;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 46px;
  padding: 0 42px 0 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  color: var(--text);
  box-shadow: var(--shadow-md);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring), var(--shadow-md);
}

/* Hide default webkit clear icon so our custom button is clean */
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.search-clear:hover {
  background: var(--border);
  color: var(--text);
}

.category-filters {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.cat-pill:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.cat-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.cat-count {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-muted);
}

.cat-pill.active .cat-count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

/* Results Bar */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 0 2px;
}

.results-count {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.lang-sync-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Tools Grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-md);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  min-width: 0;
}

.tool-card:hover {
  transform: translateY(-3px);
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: var(--shadow-hover);
}

.tool-card:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring), var(--shadow-hover);
}

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

.tool-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tone-blue { background: #eff6ff; color: #2563eb; }
.tone-indigo { background: #eef2ff; color: #4f46e5; }
.tone-emerald { background: #ecfdf5; color: #059669; }
.tone-amber { background: #fffbeb; color: #d97706; }
.tone-purple { background: #f5f3ff; color: #7c3aed; }
.tone-rose { background: #fff1f2; color: #e11d48; }
.tone-cyan { background: #ecfeff; color: #0891b2; }
.tone-slate { background: #f1f5f9; color: #334155; }
.tone-teal { background: #f0fdfa; color: #0d9488; }

.tool-cat-tag {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-subtle);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.tool-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.tool-desc {
  margin: 0 0 18px;
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1;
}

.tool-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-subtle);
}

.tool-domain {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.tool-cta svg {
  transition: transform 0.16s ease;
}

.tool-card:hover .tool-cta svg {
  transform: translateX(3px);
}

/* Empty State */
.empty-card {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 44px 20px;
  text-align: center;
  max-width: 480px;
  margin: 12px auto 0;
}

.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.empty-desc {
  margin: 0 0 16px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.btn-reset {
  border: none;
  background: var(--primary);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  transition: background-color 0.15s ease;
}

.btn-reset:hover {
  background: var(--primary-hover);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  margin-top: auto;
}

.footer-inner {
  padding-top: 18px;
  padding-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-link {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.footer-sep {
  color: var(--border-strong);
}

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 960px) {
  .tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .main-content {
    padding-top: 22px;
    padding-bottom: 34px;
  }

  .tools-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .brand-badge,
  .github-label {
    display: none;
  }

  .icon-pill-link {
    padding: 7px 9px;
  }

  .dev-link {
    padding: 6px 11px;
    font-size: 0.82rem;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 420px) {
  .container {
    padding: 0 14px;
  }

  .brand-text h1 {
    font-size: 1rem;
  }

  .dev-link .external-icon {
    display: none;
  }
}
