:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1a2033;
  --text-2: #5b6478;
  --line: #e6e9f2;
  --accent: #4f6ef7;
  --accent-soft: #eef1fe;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 8px 24px rgba(20, 30, 60, .06);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #0e1118;
  --surface: #171b26;
  --text: #e8eaf2;
  --text-2: #9aa3b8;
  --line: #262c3b;
  --accent: #7b93ff;
  --accent-soft: #1d2440;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .25s, color .25s;
}

.container { width: min(1180px, 92vw); margin: 0 auto; }

a { color: inherit; text-decoration: none; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #4f6ef7, #9b5cf6);
  color: #fff; font-size: 13px; font-weight: 800;
}
.brand-name em { font-style: normal; color: var(--accent); }
.topnav { display: flex; align-items: center; gap: 22px; font-size: 14px; color: var(--text-2); }
.topnav a:hover { color: var(--text); }
#themeToggle { cursor: pointer; font-size: 17px; }

/* ---------- hero ---------- */
.hero {
  padding: 64px 0 40px;
  text-align: center;
  background:
    radial-gradient(600px 240px at 20% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent),
    radial-gradient(600px 240px at 80% 0%, color-mix(in srgb, #9b5cf6 12%, transparent), transparent);
}
.hero-title { font-size: clamp(28px, 4.5vw, 44px); margin: 0 0 10px; letter-spacing: .5px; }
.hero-title span {
  background: linear-gradient(90deg, var(--accent), #9b5cf6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--text-2); margin: 0 0 28px; font-size: 15px; }

.search {
  position: relative;
  display: flex; align-items: center;
  width: min(560px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.search:focus-within { border-color: var(--accent); }
.search-icon { padding: 0 4px 0 18px; font-size: 15px; }
.search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  padding: 14px 8px; font-size: 15px; color: var(--text);
}
.search-clear {
  border: 0; background: transparent; color: var(--text-2);
  padding: 0 16px; cursor: pointer; font-size: 14px;
}

.quick-tags { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.quick-tags button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 4px 14px; font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.quick-tags button:hover, .quick-tags button.active {
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft);
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px;
  padding: 36px 0 60px;
  align-items: start;
}

.sidebar {
  position: sticky; top: 78px;
  display: flex; flex-direction: column; gap: 2px;
  max-height: calc(100vh - 100px); overflow: auto;
}
.cat-btn {
  display: flex; align-items: center; justify-content: space-between;
  border: 0; background: transparent; color: var(--text-2);
  text-align: left; padding: 9px 12px; border-radius: 10px;
  font-size: 14px; cursor: pointer; transition: all .15s;
}
.cat-btn:hover { color: var(--text); background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.cat-btn.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.cat-btn .count { font-size: 12px; color: var(--text-2); }

.content-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.result-meta { font-size: 13px; color: var(--text-2); }
.sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.sort select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; font-size: 13px; outline: none; cursor: pointer;
}

.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; margin: 28px 0 14px;
}
.section-title:first-child { margin-top: 0; }
.section-title .bar { width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.section-title small { color: var(--text-2); font-weight: 400; }

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

.card {
  display: flex; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card-logo {
  width: 44px; height: 44px; flex: none;
  border-radius: 11px; background: var(--accent-soft);
  display: grid; place-items: center; overflow: hidden;
  font-size: 20px; font-weight: 700; color: var(--accent);
}
.card-logo img { width: 26px; height: 26px; object-fit: contain; }.card-body { min-width: 0; }
.card-name {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; flex: none; }
.badge.hot { background: #fff1e7; color: #e8630c; }
.badge.free { background: #e8f8ef; color: #17a04c; }
[data-theme="dark"] .badge.hot { background: #3a2415; }
[data-theme="dark"] .badge.free { background: #12301f; }
.card-desc {
  color: var(--text-2); font-size: 12.5px; margin: 3px 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.6em;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-tags span {
  font-size: 11.5px; color: var(--text-2);
  background: color-mix(in srgb, var(--bg) 60%, var(--accent-soft));
  border-radius: 5px; padding: 1px 7px;
}

.empty { text-align: center; color: var(--text-2); padding: 60px 0; }
.btn {
  border: 1px solid var(--accent); color: var(--accent); background: transparent;
  border-radius: 999px; padding: 7px 22px; cursor: pointer; font-size: 14px;
}
.btn:hover { background: var(--accent-soft); }

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  padding: 26px 0 34px;
  text-align: center; font-size: 13px; color: var(--text-2);
  background: var(--surface);
}
.footer .muted { color: var(--text-2); opacity: .8; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static; flex-direction: row; flex-wrap: wrap;
    max-height: none; gap: 6px;
  }
  .cat-btn { border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; font-size: 13px; }
  .cat-btn .count { display: none; }
  .hero { padding: 44px 0 30px; }
}
