:root {
  --bg: #e8f0f6;
  --bg-grid: rgba(26, 111, 219, 0.06);
  --primary: #1a6fdb;
  --primary-soft: #e8f1fc;
  --text: #1a2332;
  --muted: #5a6578;
  --card: #ffffff;
  --border: #d5e0ea;
  --shadow: 0 8px 24px rgba(26, 35, 50, 0.06);
  --radius: 12px;
  --font-display: "DM Sans", "Source Sans 3", system-ui, sans-serif;
  --font-body: "Source Sans 3", "DM Sans", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

.page {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
}

.site-header {
  margin-bottom: 1.75rem;
}

.site-eyebrow {
  margin: 0 0 0.5rem;
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.site-en {
  color: var(--muted);
  font-weight: 500;
}

.site-tagline {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.search-label {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

#search-input {
  width: 100%;
  max-width: 420px;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  box-shadow: var(--shadow);
}

#search-input::placeholder {
  color: #8a94a6;
}

#search-input:focus-visible,
.tool-domain:focus-visible,
.tool-visit:focus-visible {
  outline: 3px solid rgba(26, 111, 219, 0.35);
  outline-offset: 2px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.15rem 1.2rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  animation: card-in 0.45s ease both;
}

.tool-card:nth-child(1) { animation-delay: 0.02s; }
.tool-card:nth-child(2) { animation-delay: 0.05s; }
.tool-card:nth-child(3) { animation-delay: 0.08s; }
.tool-card:nth-child(4) { animation-delay: 0.11s; }
.tool-card:nth-child(5) { animation-delay: 0.14s; }
.tool-card:nth-child(6) { animation-delay: 0.17s; }
.tool-card:nth-child(7) { animation-delay: 0.2s; }
.tool-card:nth-child(8) { animation-delay: 0.23s; }
.tool-card:nth-child(9) { animation-delay: 0.26s; }
.tool-card:nth-child(10) { animation-delay: 0.29s; }
.tool-card:nth-child(11) { animation-delay: 0.32s; }
.tool-card:nth-child(12) { animation-delay: 0.35s; }
.tool-card:nth-child(13) { animation-delay: 0.38s; }

.tool-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(26, 111, 219, 0.12);
}

.tool-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.tool-name a {
  color: inherit;
  text-decoration: none;
}

.tool-name a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.tool-name a:focus-visible {
  outline: 3px solid rgba(26, 111, 219, 0.35);
  outline-offset: 2px;
  border-radius: 4px;
}

.tool-domain {
  color: var(--primary);
  font-size: 0.9rem;
  text-decoration: none;
  word-break: break-all;
}

.tool-domain:hover {
  text-decoration: underline;
}

.tool-desc-zh,
.tool-desc-en {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.tool-desc-en {
  font-style: italic;
}

.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.15rem 0 0.35rem;
  padding: 0;
  list-style: none;
}

.tool-tags li {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
}

.tool-visit {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.tool-visit:hover {
  background: #155bb8;
}

.empty-state {
  margin: 2rem 0 0;
  padding: 1.25rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
}

.empty-state[hidden] {
  display: none;
}

.site-footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .tool-card {
    animation: none;
  }

  .tool-card:hover,
  .tool-visit:hover {
    transform: none;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 1.25rem, 1120px);
    padding-top: 1.75rem;
  }

  #search-input {
    max-width: none;
  }
}
