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

:root {
  --indigo: #4f46e5;
  --indigo-light: #6366f1;
  --indigo-pale: #eef2ff;
  --indigo-border: #c7d2fe;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --bg: #f8fafc;
  --white: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.05);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.1), 0 12px 32px rgba(0,0,0,0.07);
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: var(--indigo);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
}

.logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.badge {
  background: var(--indigo-pale);
  color: var(--indigo);
  border: 1px solid var(--indigo-border);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.hero {
  text-align: center;
  padding: 64px 0 32px;
  transition: padding 0.3s ease;
}

.hero.compact {
  padding: 32px 0 20px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--indigo-pale), #dbeafe);
  border: 1px solid var(--indigo-border);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--indigo);
  font-weight: 500;
  margin-bottom: 24px;
}

h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.6rem, 4vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  background: linear-gradient(135deg, #111827 0%, #3730a3 50%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 480px;
  margin: 0 auto 36px;
  line-height: 1.7;
}

.search-wrap {
  max-width: 680px;
  margin: 0 auto;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: var(--indigo-light);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.1), var(--shadow);
}

.search-box.loading { border-color: #a5b4fc; }

.search-icon {
  color: var(--text-faint);
  font-size: 18px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  color: var(--text);
  background: transparent;
}

.search-input::placeholder { color: var(--text-faint); }
.search-input:disabled { opacity: 0.6; }

.clear-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #f3f4f6;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.clear-btn:hover { background: #e5e7eb; }

.search-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--indigo);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}

.search-btn:hover:not(:disabled) { background: #4338ca; }
.search-btn:active:not(:disabled) { transform: scale(0.97); }
.search-btn:disabled { opacity: 0.4; cursor: not-allowed; }

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #c7d2fe;
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.section-label {
  text-align: center;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--text-faint);
  margin: 28px 0 14px;
}

.categories {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 480px) { .categories { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 700px) { .categories { grid-template-columns: repeat(4, 1fr); } }

.cat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: left;
  transition: all 0.15s;
  box-shadow: var(--shadow);
}

.cat-btn:hover {
  border-color: var(--indigo-border);
  background: var(--indigo-pale);
  color: var(--indigo);
  transform: translateY(-1px);
}

.cat-emoji { font-size: 1.2rem; }

.error-box {
  max-width: 600px;
  margin: 24px auto;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  gap: 12px;
}

.error-box.api-error { background: #fffbeb; border: 1px solid #fde68a; }
.error-box.generic-error { background: #fef2f2; border: 1px solid #fecaca; }
.error-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }

.error-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.api-error .error-title { color: #92400e; }
.generic-error .error-title { color: #991b1b; }

.error-desc { font-size: 0.875rem; }
.api-error .error-desc { color: #b45309; }
.generic-error .error-desc { color: #dc2626; }

.error-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 0.85rem;
  text-decoration: underline;
  color: #b45309;
}

.retry-btn {
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.85rem;
  color: #dc2626;
  margin-top: 8px;
  font-family: 'DM Sans', sans-serif;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.skeleton-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 24px;
}

@media (min-width: 540px) { .skeleton-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .skeleton-grid { grid-template-columns: repeat(3, 1fr); } }

.skeleton-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  animation: pulse 1.5s ease-in-out infinite;
}

.skel { background: #f3f4f6; border-radius: 6px; }
.skel-circle { border-radius: 12px; }

.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  margin-top: 8px;
}

.results-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--indigo-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 4px;
}

.results-intro { color: var(--text-muted); font-size: 0.95rem; }

.new-search-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--indigo);
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  padding: 4px 0;
}

.new-search-btn:hover { text-decoration: underline; }

.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 540px) { .results-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .results-grid { grid-template-columns: repeat(3, 1fr); } }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.site-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
  animation: fadeSlideIn 0.35s ease both;
}

.site-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: #d1d5db;
  transform: translateY(-2px);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-logo-wrap { display: flex; align-items: center; gap: 10px; }

.card-emoji {
  width: 44px;
  height: 44px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.card-name {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  transition: color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.site-card:hover .card-name { color: var(--indigo); }

.card-url {
  font-size: 0.75rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.ext-icon { font-size: 14px; color: #d1d5db; flex-shrink: 0; }
.site-card:hover .ext-icon { color: var(--indigo-light); }

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-best { font-size: 0.78rem; color: var(--indigo-light); font-style: italic; }

.card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-top: 4px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  border: 1px solid;
}

.tag-highlight { background: #fffbeb; color: #b45309; border-color: #fde68a; margin-left: auto; }
.tag-free { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; margin-left: auto; }
.tag-design { background: #faf5ff; color: #7c3aed; border-color: #e9d5ff; }
.tag-ai { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.tag-productivity { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.tag-learning { background: #fefce8; color: #a16207; border-color: #fef08a; }
.tag-code { background: #f8fafc; color: #334155; border-color: #e2e8f0; }
.tag-cloud { background: #f0f9ff; color: #0369a1; border-color: #bae6fd; }
.tag-communication { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.tag-video { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.tag-music { background: #fdf2f8; color: #9d174d; border-color: #fbcfe8; }
.tag-finance { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.tag-job { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.tag-default { background: #f9fafb; color: #374151; border-color: #e5e7eb; }

.explore-more {
  margin-top: 40px;
  background: linear-gradient(135deg, var(--indigo-pale), #dbeafe30);
  border: 1px solid var(--indigo-border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
}

.explore-more p { color: var(--text-muted); margin-bottom: 14px; font-size: 0.95rem; }

.explore-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.explore-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--indigo-border);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 0.85rem;
  color: var(--indigo);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}

.explore-tag:hover { background: var(--indigo-pale); transform: translateY(-1px); }

.other-projects {
  margin-top: 56px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow);
}

.other-projects .section-label { margin-top: 0; }

.project-card {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: var(--indigo-pale);
  border: 1px solid var(--indigo-border);
  border-radius: var(--radius);
  padding: 16px 24px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  margin-top: 16px;
}

.project-card:hover { background: #e0e7ff; transform: translateY(-2px); }
.project-icon { font-size: 1.8rem; }

.project-name {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  color: var(--indigo);
  font-size: 0.95rem;
}

.project-desc { font-size: 0.8rem; color: #6366f1; margin-top: 2px; }

.loading-row { display: flex; align-items: center; gap: 10px; margin: 20px 0 16px; }
.loading-text { font-size: 0.875rem; color: var(--text-faint); }

footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-faint);
}

.hidden { display: none !important; }