:root {
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-sec: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --accent-glow: rgba(79, 70, 229, 0.15);
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

header {
  position: relative;
  text-align: center;
  padding: 56px 20px 40px;
  overflow: hidden;
}

.header-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  z-index: 0;
}

.header-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.header-content { position: relative; z-index: 1; }

header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: white;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.subtitle {
  color: rgba(255,255,255,0.85);
  font-size: 1.05rem;
  margin-bottom: 28px;
  font-weight: 400;
}

.search-bar {
  max-width: 520px;
  margin: 0 auto 20px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-sec);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  outline: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  transition: box-shadow var(--transition);
  background: white;
}

.search-bar input:focus {
  box-shadow: 0 4px 24px rgba(0,0,0,0.2), 0 0 0 3px var(--accent-glow);
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto 12px;
}

.category-filters button {
  padding: 7px 18px;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.1);
  color: white;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
}

.category-filters button:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.7);
}

.category-filters button.active {
  background: white;
  color: var(--accent);
  border-color: white;
  font-weight: 600;
}

.stats {
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  margin-top: 4px;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  min-height: 40vh;
}

.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.site-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.site-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  opacity: 0;
  transition: opacity var(--transition);
}

.site-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

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

.card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--accent);
  font-weight: 700;
}

.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-name {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

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

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

.card-category {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

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

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-sec);
  grid-column: 1 / -1;
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 1.05rem; }

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px;
  color: var(--text-sec);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-sec);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  background: white;
}

footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

footer a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  header { padding: 40px 16px 28px; }
  header h1 { font-size: 1.6rem; }
  .subtitle { font-size: 0.95rem; }
  .sites-grid { grid-template-columns: 1fr; }
  main { padding: 20px 12px 40px; }
}
