:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #1a1f2e;
  --text-dim: #5b6478;
  --text-faint: #8b93a7;
  --border: #e4e8f0;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --shadow: 0 6px 24px rgba(28, 35, 64, 0.08);
  --shadow-hover: 0 12px 36px rgba(28, 35, 64, 0.16);
  --radius: 16px;
  --maxw: 1180px;
}

[data-theme="dark"] {
  --bg: #0e1118;
  --surface: #171b25;
  --surface-2: #1f2533;
  --text: #e8ebf2;
  --text-dim: #a4adbf;
  --text-faint: #6b7488;
  --border: #262d3d;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-soft: #1e2233;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 12px 36px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

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

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-logo { font-size: 26px; }
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.brand-sub { font-size: 12px; color: var(--text-faint); }

.search-wrap { flex: 1; display: flex; }
#search {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.actions { display: flex; gap: 8px; }
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: transform .12s, background .2s, border-color .2s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn.icon { padding: 9px 11px; }
.btn.outline { background: transparent; }

/* Categories */
.cats {
  max-width: var(--maxw);
  margin: 14px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
}
.chip:hover { color: var(--text); }
.chip.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
}

/* Layout */
.container { max-width: var(--maxw); margin: 0 auto; padding: 18px 20px 40px; }
.status { font-size: 13px; color: var(--text-faint); margin: 4px 2px 16px; min-height: 18px; }

/* Featured */
.featured { margin-bottom: 26px; }
.featured-card {
  position: relative;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: pointer;
  min-height: 240px;
}
.featured-card:hover { box-shadow: var(--shadow-hover); }
.featured-visual {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; color: rgba(255,255,255,.9);
}
.featured-visual img { width: 100%; height: 100%; object-fit: cover; }
.featured-body { padding: 26px 28px; display: flex; flex-direction: column; justify-content: center; }
.featured-tag {
  align-self: flex-start;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
  color: var(--accent); background: var(--accent-soft);
  padding: 4px 10px; border-radius: 999px; margin-bottom: 12px;
}
.featured-body h2 { margin: 0 0 10px; font-size: 24px; line-height: 1.3; }
.featured-body p { margin: 0 0 16px; color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.featured-meta { font-size: 12px; color: var(--text-faint); }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
  animation: rise .4s ease both;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.card-thumb {
  height: 150px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; color: rgba(255,255,255,.85);
  position: relative;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb .thumb-fallback,
.featured-visual .thumb-fallback {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--thumb-color, var(--accent)), color-mix(in srgb, var(--thumb-color, var(--accent)) 70%, #2e1065));
  display: flex; align-items: center; justify-content: center;
  font-size: 56px; font-weight: 800; color: rgba(255,255,255,.92);
  text-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.featured-visual .thumb-fallback { font-size: 80px; }
.card-cat {
  position: absolute; left: 12px; top: 12px;
  font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.35); backdrop-filter: blur(4px);
  padding: 4px 10px; border-radius: 999px;
}
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.card-body h3 { margin: 0 0 8px; font-size: 16px; line-height: 1.45; }
.card-body p { margin: 0 0 14px; color: var(--text-dim); font-size: 13px; line-height: 1.6; flex: 1; }
.card-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-faint); }
.card-source { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-dim); }
.card-source img { width: 16px; height: 16px; border-radius: 4px; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Skeleton */
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.card.sk { pointer-events: none; }
.card.sk .card-thumb { background: var(--surface-2); animation: pulse 1.3s infinite; }
.sk-line { height: 12px; border-radius: 6px; background: var(--surface-2); margin: 8px 18px; animation: pulse 1.3s infinite; }
.sk-line.short { width: 50%; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.loadmore-wrap { text-align: center; margin-top: 28px; }

.footer {
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  display: flex; flex-direction: column; gap: 6px;
}

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

@media (max-width: 720px) {
  .featured-card { grid-template-columns: 1fr; }
  .featured-visual { min-height: 140px; }
  .brand-sub { display: none; }
  .topbar-inner { flex-wrap: wrap; }
  .search-wrap { order: 3; flex-basis: 100%; }
  #search { margin: 0; max-width: none; }
}
