:root {
  --bg: #07080d;
  --bg-elev: #0e1118;
  --card: rgba(20, 23, 33, 0.55);
  --card-border: rgba(255, 255, 255, 0.07);
  --fg: #e6eaf2;
  --fg-dim: #8a93a6;
  --fg-mute: #5d667a;
  --accent-1: #3ab7ff;
  --accent-2: #a78bfa;
  --accent-grad: linear-gradient(135deg, #3ab7ff 0%, #a78bfa 100%);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --radius: 16px;
}

[data-theme="light"] {
  --bg: #f7f8fb;
  --bg-elev: #ffffff;
  --card: rgba(255, 255, 255, 0.75);
  --card-border: rgba(15, 23, 42, 0.08);
  --fg: #0f172a;
  --fg-dim: #475569;
  --fg-mute: #94a3b8;
  --shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Hiragino Kaku Gothic ProN", "Yu Gothic",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}
[data-theme="light"] body::before {
  background-image:
    linear-gradient(to right, rgba(15,23,42,0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15,23,42,0.045) 1px, transparent 1px);
}

.bg-blob {
  position: fixed;
  width: 520px; height: 520px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.32;
  pointer-events: none;
  z-index: 0;
}
.bg-blob-1 { background: radial-gradient(circle, #3ab7ff 0%, transparent 70%); top: -200px; left: -120px; }
.bg-blob-2 { background: radial-gradient(circle, #a78bfa 0%, transparent 70%); bottom: -240px; right: -160px; }
[data-theme="light"] .bg-blob { opacity: 0.18; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--card-border);
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--fg);
  font-weight: 700; font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-mark {
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  font-size: 22px;
}
.topbar-tools { display: flex; align-items: center; gap: 10px; }

.search { position: relative; }
.search input {
  width: 280px;
  padding: 9px 14px 9px 36px;
  background: var(--bg-elev);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s, width .2s;
}
.search input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(58,183,255,.14);
}
.search::before {
  content: "🔍";
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 13px; opacity: .55;
  pointer-events: none;
}

.select-pill {
  background: var(--bg-elev);
  border: 1px solid var(--card-border);
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 28px 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238a93a6' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.select-pill:focus { border-color: var(--accent-1); }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--card-border);
  color: var(--fg);
  border-radius: 999px;
  cursor: pointer;
  font-size: 16px;
  transition: transform .25s, border-color .2s;
}
.icon-btn:hover { transform: rotate(-15deg); border-color: var(--accent-1); }

.shell {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 180px;
  gap: 36px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 36px 28px 64px;
}
@media (max-width: 1280px) {
  .shell { grid-template-columns: 1fr; gap: 16px; }
  .ad-rail { display: none; }
}

.ad-rail { position: sticky; top: 86px; align-self: start; }
.ad-placeholder {
  height: 600px; width: 160px;
  margin: 0 auto;
  border: 1px dashed var(--card-border);
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  color: var(--fg-mute);
  font-size: 11px;
  text-align: center;
  padding: 20px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.015) 0%, transparent 100%);
}
.ad-placeholder-title {
  font-weight: 700; font-size: 13px;
  letter-spacing: 0.08em;
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.ad-placeholder .hint { opacity: .8; line-height: 1.5; }

.hero { margin-bottom: 40px; }
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--fg) 0%, var(--fg) 30%, var(--accent-1) 70%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { margin: 0; color: var(--fg-dim); font-size: 15px; }

.category { margin-bottom: 44px; scroll-margin-top: 80px; }
.category-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
}
.category-head .icon { font-size: 18px; }
.category-head h2 {
  margin: 0; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--fg);
}
.category-head .count {
  color: var(--fg-mute);
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
}
.category-line { flex: 1; height: 1px; background: var(--card-border); }

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

.card {
  position: relative;
  display: flex; flex-direction: column;
  padding: 18px;
  background: var(--card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: transform .25s ease, box-shadow .25s, border-color .25s;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  background: var(--accent-grad);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card:hover::before { opacity: 1; }
.card:hover .card-arrow { opacity: 1; transform: translate(2px, -2px); }

.card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.card-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--card-border);
  flex-shrink: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  color: var(--fg-dim);
}
.card-icon img { width: 22px; height: 22px; object-fit: contain; }
.card-meta { min-width: 0; flex: 1; }
.card-name {
  font-size: 15px; font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-domain {
  font-size: 12px; color: var(--fg-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-arrow {
  margin-left: auto;
  opacity: 0;
  transition: all .25s;
  color: var(--accent-1);
  font-size: 16px;
  flex-shrink: 0;
}

.card-desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--fg-dim);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: rgba(58, 183, 255, 0.10);
  border: 1px solid rgba(58, 183, 255, 0.28);
  border-radius: 999px;
  font-size: 11px;
  color: #8ad0ff;
  width: fit-content;
  max-width: 100%;
  line-height: 1.4;
  margin-top: auto;
}
[data-theme="light"] .badge {
  color: #1d4ed8;
  background: rgba(58, 183, 255, 0.08);
  border-color: rgba(58, 183, 255, 0.32);
}
.badge::before {
  content: "🎁";
  font-size: 11px;
  flex-shrink: 0;
}
.badge-text {
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--fg-mute);
  font-size: 14px;
}

.footer {
  position: relative; z-index: 1;
  text-align: center;
  padding: 24px 16px;
  color: var(--fg-mute);
  font-size: 13px;
  border-top: 1px solid var(--card-border);
  margin-top: 40px;
}
.footer .dot { margin: 0 8px; opacity: 0.4; }

@media (max-width: 720px) {
  .topbar-inner { padding: 12px 16px; gap: 8px; }
  .search input { width: 140px; }
  .search input:focus { width: 200px; }
  .shell { padding: 24px 16px 48px; }
  .hero { margin-bottom: 28px; }
  .cards { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
