/* ============ 主题变量 ============ */
:root {
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1180px;
  --accent: #5b8cff;
  --accent-2: #8b5cf6;
  --quark: #6c5ce7;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", system-ui, -apple-system, sans-serif;
  --speed: .18s;
}

html[data-theme="dark"] {
  --bg: #0b0f19;
  --bg-soft: #111726;
  --card: #141b2d;
  --card-hover: #1a2338;
  --border: #232c44;
  --text: #e8ecf5;
  --text-dim: #9aa5bd;
  --text-faint: #6b7690;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --glow: radial-gradient(900px 420px at 15% -10%, rgba(91, 140, 255, .22), transparent 60%),
          radial-gradient(700px 380px at 92% 0%, rgba(139, 92, 246, .18), transparent 62%);
}

html[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-hover: #ffffff;
  --border: #e3e8f2;
  --text: #17203a;
  --text-dim: #5b678a;
  --text-faint: #8b95b0;
  --shadow: 0 8px 24px rgba(23, 32, 58, .09);
  --glow: radial-gradient(900px 420px at 15% -10%, rgba(91, 140, 255, .16), transparent 60%),
          radial-gradient(700px 380px at 92% 0%, rgba(139, 92, 246, .12), transparent 62%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--glow);
  background-repeat: no-repeat;
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ============ 顶栏 ============ */
.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 26px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 17px; letter-spacing: .3px; }
.brand-text small { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.ghost-btn {
  border: 1px solid var(--border); background: transparent; color: var(--text-dim);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: var(--speed);
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); background: rgba(91, 140, 255, .1); }

/* ============ Hero ============ */
.hero { padding: 54px 0 26px; text-align: center; }
.hero h1 { font-size: clamp(24px, 4.4vw, 40px); margin: 0 0 12px; letter-spacing: -.5px; }
.hero h1 em { font-style: normal; background: linear-gradient(96deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--text-dim); margin: 0 auto 26px; max-width: 620px; font-size: 15px; }

.searchbar {
  display: flex; align-items: center; gap: 10px;
  max-width: 640px; margin: 0 auto;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 18px;
  box-shadow: var(--shadow); transition: var(--speed);
}
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(91, 140, 255, .16); }
.searchbar input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 15px; font-family: inherit; min-width: 0; }
.searchbar input::placeholder { color: var(--text-faint); }
.search-icon { opacity: .65; }
.clear-btn { border: 0; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 14px; }

.quick-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.stat-chip {
  font-size: 12.5px; color: var(--text-dim);
  border: 1px dashed var(--border); border-radius: 999px; padding: 5px 13px;
}
.stat-chip b { color: var(--accent); font-weight: 600; }

/* ============ 工具栏 ============ */
.main { padding-bottom: 60px; }
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; margin: 10px 0 22px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.cats { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text-dim);
  padding: 7px 15px; border-radius: 999px; font-size: 13.5px; cursor: pointer;
  font-family: inherit; transition: var(--speed); white-space: nowrap;
}
.cat-btn:hover { color: var(--text); transform: translateY(-1px); }
.cat-btn.active {
  background: linear-gradient(96deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff; font-weight: 600;
}
.cat-btn .count { opacity: .68; font-size: 11.5px; margin-left: 4px; }
.sorts { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-faint); }
.sorts select {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 10px; font-size: 13px; font-family: inherit; cursor: pointer;
}

/* ============ 公告 ============ */
.notice {
  background: linear-gradient(90deg, rgba(91, 140, 255, .14), rgba(139, 92, 246, .1));
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13.5px;
  color: var(--text-dim); margin-bottom: 22px;
}
.notice b { color: var(--text); }

/* ============ 卡片网格 ============ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 12px;
  transition: var(--speed); position: relative; overflow: hidden;
}
.card::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0; transition: var(--speed);
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: var(--shadow); }
.card:hover::after { opacity: 1; }

.card-top { display: flex; align-items: flex-start; gap: 12px; }
.card-icon {
  flex: none; width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center; font-size: 21px;
  background: linear-gradient(135deg, rgba(91, 140, 255, .2), rgba(139, 92, 246, .18));
  border: 1px solid var(--border);
}
.card-head { min-width: 0; flex: 1; }
.card-title { font-size: 15.5px; font-weight: 650; margin: 0 0 3px; line-height: 1.35; word-break: break-word; }
.card-cat { font-size: 11.5px; color: var(--text-faint); }
.badge-hot {
  flex: none; font-size: 10.5px; font-weight: 700; color: #fff;
  background: linear-gradient(96deg, #ff6b6b, #ff9f43);
  padding: 2.5px 7px; border-radius: 6px; letter-spacing: .4px;
}
.card-desc { font-size: 13px; color: var(--text-dim); margin: 0; flex: 1; word-break: break-word; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11.5px; color: var(--text-dim); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px;
}

.meta {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  font-size: 11.5px; color: var(--text-faint);
  padding-top: 11px; border-top: 1px dashed var(--border);
}
.meta span { display: inline-flex; align-items: center; gap: 4px; }
.code-pill {
  font-family: ui-monospace, Consolas, monospace; color: var(--accent);
  background: rgba(91, 140, 255, .12); border-radius: 5px; padding: 0 5px; cursor: pointer;
}

.card-actions { display: flex; gap: 8px; }
.primary-btn {
  flex: 1; border: 0; cursor: pointer; font-family: inherit;
  background: linear-gradient(96deg, var(--accent), var(--quark));
  color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 16px; border-radius: var(--radius-sm);
  transition: var(--speed); display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.primary-btn:hover { filter: brightness(1.1); box-shadow: 0 6px 20px rgba(91, 140, 255, .38); }
.primary-btn:active { transform: scale(.985); }
.primary-btn:disabled { background: var(--border); color: var(--text-faint); cursor: not-allowed; box-shadow: none; }
.icon-btn {
  flex: none; width: 42px; border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); border-radius: var(--radius-sm); cursor: pointer;
  font-size: 15px; transition: var(--speed);
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); background: rgba(91, 140, 255, .1); }

/* ============ 空状态 ============ */
.empty { text-align: center; padding: 70px 20px; color: var(--text-dim); }
.empty-emoji { font-size: 46px; margin-bottom: 12px; }
.empty p { font-size: 17px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
.empty span { font-size: 13.5px; color: var(--text-faint); display: block; margin-bottom: 20px; }
.empty .primary-btn { flex: none; padding: 10px 24px; }

/* ============ 页脚 ============ */
.site-footer { border-top: 1px solid var(--border); padding: 30px 0 40px; background: var(--bg-soft); }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13.5px; margin-bottom: 14px; }
.footer-links a { color: var(--text-dim); transition: var(--speed); }
.footer-links a:hover { color: var(--accent); }
.disclaimer { font-size: 12.5px; color: var(--text-faint); margin: 0 0 8px; line-height: 1.7; }
.copyright { font-size: 12px; color: var(--text-faint); margin: 0; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 22px);
  background: #101827; color: #fff; border: 1px solid rgba(255, 255, 255, .12);
  padding: 11px 20px; border-radius: 999px; font-size: 13.5px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .4);
  opacity: 0; pointer-events: none; transition: .26s; z-index: 90; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ 响应式 ============ */
@media (max-width: 640px) {
  .hero { padding: 34px 0 18px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  /* flex-wrap 必须是 nowrap：否则多行 flex 容器的 stretch 按「行」宽度拉伸，分类栏会撑破页面 */
  .toolbar { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
  .sorts { justify-content: space-between; }
  .sorts select { flex: 1; }
  .cats { overflow-x: auto; flex-wrap: nowrap; min-width: 0; max-width: 100%; padding-bottom: 4px; scrollbar-width: none; }
  .cats::-webkit-scrollbar { display: none; }
  .brand-text small { display: none; }
}
