/* ===========================================================
   资源站 · 样式表
   改配色：只动下面的 :root / [data-theme="dark"] 两组变量
   =========================================================== */

:root {
  --bg: #f5f6fa;
  --bg-glow: rgba(79, 70, 229, 0.10);
  --panel: #ffffff;
  --panel-soft: #fafbfe;
  --text: #11131a;
  --text-2: #3d4354;
  --muted: #6b7285;
  --border: #e5e8f0;
  --border-strong: #d4d9e6;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --ok: #0f9d58;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 2px 4px rgba(16, 24, 40, .04), 0 14px 32px -18px rgba(16, 24, 40, .35);
  --radius: 16px;
  --maxw: 1180px;
}

[data-theme="dark"] {
  --bg: #0a0c11;
  --bg-glow: rgba(124, 58, 237, 0.22);
  --panel: #12151d;
  --panel-soft: #151925;
  --text: #e9ecf4;
  --text-2: #c2c8d6;
  --muted: #8d96aa;
  --border: #232936;
  --border-strong: #2e3546;
  --accent: #8b8cf7;
  --accent-2: #b18cff;
  --accent-ink: #0b0d12;
  --accent-soft: #1b1e33;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, .45), 0 18px 36px -20px #000;
}

* { box-sizing: border-box; }

/* 关键：让 JS 里的 hidden 属性真正生效（否则会被 .card{display:flex} 覆盖） */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: 128px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: -20% 0 auto 0;
  height: 520px;
  background: radial-gradient(60% 100% at 50% 0%, var(--bg-glow), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

::selection { background: var(--accent); color: var(--accent-ink); }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  box-shadow: 0 6px 16px -8px #4f46e5;
}
.logo svg { width: 19px; height: 19px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .2px; }
.brand-text em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .3px;
}

.theme-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  transition: border-color .18s, color .18s, transform .18s;
}
.theme-btn:hover { border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }
.theme-btn svg { width: 17px; height: 17px; }
.theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: block; }
[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* ---------------- 头部区 ---------------- */
.hero { padding: 46px 0 6px; position: relative; z-index: 1; }
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 4.2vw, 41px);
  line-height: 1.25;
  letter-spacing: -.6px;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent) 75%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--text);
}
.hero-sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 15px;
  max-width: 620px;
}

.search-wrap {
  position: relative;
  max-width: 620px;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 17px;
  width: 18px; height: 18px;
  color: var(--muted);
  pointer-events: none;
}
#q {
  width: 100%;
  height: 52px;
  padding: 0 54px 0 46px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  transition: border-color .18s, box-shadow .18s;
  appearance: none;
}
#q::placeholder { color: var(--muted); }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }
#q:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
.search-kbd {
  position: absolute;
  right: 14px;
  min-width: 22px;
  height: 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: none;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
}
.stat b { color: var(--text); font-weight: 650; }

/* ---------------- 分类导航 ---------------- */
.cats {
  position: sticky;
  top: 62px;
  z-index: 40;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 0;
  margin-bottom: 6px;
  background: linear-gradient(var(--bg) 70%, transparent);
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-color: #4f46e5;
  color: #fff;
  box-shadow: 0 8px 20px -12px #4f46e5;
}
.chip .n { opacity: .62; margin-left: 5px; font-size: 12px; }

/* ---------------- 分类区块 ---------------- */
.section { padding: 26px 0 4px; position: relative; z-index: 1; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.2px;
}
.section-head .count {
  font-size: 12.5px;
  color: var(--muted);
}
.section-head .line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* ---------------- 卡片 ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(266px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: transform .2s cubic-bezier(.2,.7,.3,1), box-shadow .2s, border-color .2s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card-head { display: flex; gap: 12px; align-items: flex-start; }

.avatar {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.4px;
  color: #fff;
  background: hsl(var(--h) 62% 50%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  overflow: hidden;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.titles { min-width: 0; flex: 1; }
.titles h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.titles p {
  margin: 3px 0 0;
  font-size: 12.8px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}
.tag.hash { cursor: help; color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, var(--border)); }

.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .16s;
  white-space: nowrap;
  min-width: 0;
}
.btn svg { width: 14px; height: 14px; }
.btn.primary {
  flex: 1;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  box-shadow: 0 8px 18px -12px #4f46e5;
}
.btn.primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn.ghost {
  background: var(--panel);
  border-color: var(--border-strong);
  color: var(--text-2);
  padding: 0 11px;
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.ghost.copied { border-color: var(--ok); color: var(--ok); }

/* ---------------- 空状态 / 页脚 / 回顶 ---------------- */
.empty {
  text-align: center;
  padding: 64px 20px 90px;
  color: var(--muted);
}
.empty p { margin: 0 0 6px; font-size: 16px; color: var(--text-2); font-weight: 600; }
.empty span { font-size: 13px; }

.footer {
  margin-top: 56px;
  border-top: 1px solid var(--border);
  padding: 26px 0 40px;
  position: relative;
  z-index: 1;
}
.footer-inner { color: var(--muted); font-size: 12.5px; }
.footer-inner p { margin: 0 0 8px; }
.footer-meta { display: flex; flex-wrap: wrap; gap: 14px; }
.footer-meta a:hover { color: var(--accent); }

.totop {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all .22s;
  z-index: 60;
}
.totop svg { width: 17px; height: 17px; }
.totop.show { opacity: 1; transform: none; pointer-events: auto; }
.totop:hover { color: var(--accent); border-color: var(--accent); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 720px) {
  .hero { padding-top: 30px; }
  .hero h1 { font-size: 26px; }
  .hero-sub { font-size: 13.5px; margin-bottom: 20px; }
  .grid { grid-template-columns: 1fr; }
  .cats { top: 58px; padding: 10px 0; }
  .topbar-inner { height: 58px; }
  #q { height: 48px; font-size: 14px; }
  .totop { right: 14px; bottom: 14px; }
  .wrap { padding: 0 16px; }
}
