:root {
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-glass-hover: rgba(255, 255, 255, 0.88);
  --bg-card: #ffffff;
  --bg-card-hover: #f5f5f7;
  --bg-sidebar: rgba(245, 245, 247, 0.85);
  --bg-input: #f5f5f7;
  --bg-badge: #f0f0f5;

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-inverse: #ffffff;

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-light: #e8f0fe;
  --success: #34c759;
  --warning: #ff9f0a;
  --danger: #ff3b30;
  --star: #ff9500;

  --border: rgba(0, 0, 0, 0.06);
  --border-hover: rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  --header-height: 52px;
  --sidebar-width: 240px;
  --content-max: 1200px;
}

[data-theme="dark"] {
  --bg-primary: #1c1c1e;
  --bg-secondary: #2c2c2e;
  --bg-glass: rgba(44, 44, 46, 0.72);
  --bg-glass-hover: rgba(44, 44, 46, 0.88);
  --bg-card: #2c2c2e;
  --bg-card-hover: #3a3a3c;
  --bg-sidebar: rgba(28, 28, 30, 0.85);
  --bg-input: #3a3a3c;
  --bg-badge: #3a3a3c;

  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #86868b;

  --accent: #2997ff;
  --accent-hover: #40a9ff;
  --accent-light: #1a3a5c;

  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== HEADER ===== */
.nav-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
}
.nav-header .logo { height: 28px; margin-right: 24px; }
.nav-header .logo img { height: 100%; }
.nav-header .nav-links { display: flex; gap: 4px; flex: 1; }
.nav-header .nav-links a {
  padding: 6px 14px; border-radius: var(--radius-full);
  color: var(--text-secondary); text-decoration: none; font-size: 14px;
  font-weight: 500; transition: all var(--transition-fast);
}
.nav-header .nav-links a:hover,
.nav-header .nav-links a.active {
  color: var(--text-primary); background: var(--bg-card-hover);
}
.nav-actions { display: flex; align-items: center; gap: 12px; }
.nav-actions .btn-search {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--bg-input); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: all var(--transition-fast);
}
.nav-actions .btn-search:hover { background: var(--bg-card-hover); }

/* ===== HERO / SEARCH ===== */
.hero-section {
  padding: calc(var(--header-height) + 60px) 24px 40px;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}
.hero-section h1 {
  font-size: 40px; font-weight: 700; letter-spacing: -0.02em;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-section p { font-size: 18px; color: var(--text-secondary); margin-bottom: 32px; }

.search-container {
  max-width: 640px; margin: 0 auto; position: relative;
}
.search-container input {
  width: 100%; height: 52px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 0 52px 0 20px;
  font-size: 16px; color: var(--text-primary);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
  outline: none;
}
.search-container input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-light), var(--shadow-md);
}
.search-container .search-icon {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary); pointer-events: none;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px; max-width: var(--content-max); margin: 0 auto;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.filter-bar .filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 16px; border-radius: var(--radius-full);
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition-fast);
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active {
  background: var(--accent); color: white; border-color: var(--accent);
}

/* ===== SORT SELECTOR ===== */
.sort-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px 16px; max-width: var(--content-max); margin: 0 auto;
}
.sort-bar .sort-label { font-size: 13px; color: var(--text-tertiary); }
.sort-bar select {
  appearance: none; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 32px 6px 12px;
  font-size: 13px; color: var(--text-primary); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2386868b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

/* ===== CARD GRID ===== */
.section-title {
  font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
  margin: 32px 0 16px; padding: 0 24px;
  max-width: var(--content-max); margin-left: auto; margin-right: auto;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; padding: 0 24px;
  max-width: var(--content-max); margin: 0 auto;
}

/* ===== SITE CARD ===== */
.site-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition-base);
  cursor: pointer;
  overflow: hidden;
}
.site-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-hover);
}

.site-card .card-header {
  display: flex; align-items: flex-start; gap: 14px; margin-bottom: 12px;
}
.site-card .card-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  background: var(--bg-input); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.site-card .card-icon img { width: 100%; height: 100%; object-fit: contain; }
.site-card .card-info { flex: 1; min-width: 0; }
.site-card .card-title {
  font-size: 16px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-card .card-desc {
  font-size: 13px; color: var(--text-secondary); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-top: 4px;
}

.site-card .card-meta {
  display: flex; align-items: center; gap: 12px; margin-top: 12px;
}
.site-card .card-rating {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--star); font-weight: 600;
}
.site-card .card-rating .count {
  color: var(--text-tertiary); font-weight: 400;
}
.site-card .card-tags {
  display: flex; gap: 4px; flex-wrap: wrap; flex: 1; justify-content: flex-end;
}
.site-card .tag {
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 500;
  background: var(--bg-badge); color: var(--text-secondary);
}

/* Visit button overlay */
.site-card .btn-visit {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--accent); color: white; border: none;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(0.8);
  transition: all var(--transition-fast);
  cursor: pointer; z-index: 2;
  font-size: 14px;
}
.site-card:hover .btn-visit { opacity: 1; transform: scale(1); }
.site-card .btn-visit:hover { background: var(--accent-hover); transform: scale(1.1); }

/* Featured badge */
.site-card .badge-featured {
  position: absolute; top: 0; left: 20px;
  background: var(--accent); color: white;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 4px 8px; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* ===== FOOTER ===== */
.site-footer {
  text-align: center; padding: 40px 24px;
  color: var(--text-tertiary); font-size: 13px;
  border-top: 0.5px solid var(--border); margin-top: 60px;
}
.site-footer a { color: var(--text-secondary); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-full);
  font-size: 14px; font-weight: 500; border: none; cursor: pointer;
  transition: all var(--transition-fast); text-decoration: none;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-card-hover); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-light); }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--bg-input); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 16px;
  transition: all var(--transition-fast);
}
.theme-toggle:hover { background: var(--bg-card-hover); }

/* ===== STAR RATING ===== */
.star-rating { display: inline-flex; gap: 2px; }
.star-rating .star {
  font-size: 18px; color: var(--border); cursor: pointer;
  transition: color var(--transition-fast);
}
.star-rating .star.filled { color: var(--star); }
.star-rating .star:hover { color: var(--star); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .hero-section h1 { font-size: 28px; }
  .hero-section p { font-size: 15px; }
  .card-grid { grid-template-columns: 1fr; }
  .nav-header .nav-links { display: none; }
  .section-title { font-size: 18px; }
}
@media (max-width: 480px) {
  .hero-section { padding-top: calc(var(--header-height) + 32px); }
  .card-grid { padding: 0 16px; }
}
