:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --border: #e6e8eb;
  --text: #16181d;
  --text-2: #5f6672;
  --text-3: #949aa4;
  --accent: #1a6ef5;
  --accent-soft: #eaf1fe;
  --good: #17803d;
  --good-soft: #e8f5ec;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --surface: #14171c;
    --surface-2: #1b1f26;
    --border: #24282f;
    --text: #e8eaed;
    --text-2: #9aa1ab;
    --text-3: #6d747e;
    --accent: #4c8dff;
    --accent-soft: #16233c;
    --good: #45b366;
    --good-soft: #14261a;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.6; min-height: 100vh; overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
svg { fill: currentColor; }

.wrap { max-width: 940px; margin: 0 auto; padding: 0 20px 60px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 40px 0 20px; }
.top h1 { font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.top .slogan { font-size: 12.5px; color: var(--text-3); margin-top: 4px; font-weight: 400; }
.stat-src { margin-left: auto; text-align: right; }
.stat-src .n { font-size: 12px; font-weight: 400; color: var(--text-3); font-variant-numeric: tabular-nums; }
.stamp { font-size: 11.5px; color: var(--text-3); align-self: center; white-space: nowrap; }
.top .meta b { color: var(--text-2); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text-2);
  padding: 8px 14px; font-size: 13px; font-weight: 500;
  transition: color .15s, border-color .15s;
}
.btn:hover { color: var(--text); border-color: var(--text-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; display: none; }
.btn.loading .spin { display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

/* Stats */
.stats { display: flex; gap: 28px; padding: 0 0 22px; flex-wrap: wrap; }
.stats .n { font-size: 19px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.stats .t { font-size: 12px; color: var(--text-3); margin-top: 1px; }

/* Filters */
.filters { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.filterrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; min-width: 0; }
.flabel {
  flex: none; width: 52px; font-size: 11.5px; color: var(--text-3);
  letter-spacing: .04em; text-align: right;
}
.hint { font-size: 12px; color: var(--text-3); }
.hint.warn { color: var(--warn, #b45309); }
.chip {
  border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text-2);
  padding: 5px 11px; font-size: 13px; white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.daterange { display: inline-flex; align-items: center; gap: 5px; }
.daterange input {
  border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text);
  padding: 5px 8px; font-size: 12.5px; font-family: inherit; min-height: 30px;
}
.daterange input:focus { outline: none; border-color: var(--accent); }
.daterange span { color: var(--text-3); font-size: 12px; }

.search { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: var(--r); padding: 0 10px; min-height: 32px; flex: 1; min-width: 180px; max-width: 300px; }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 13px; height: 13px; fill: var(--text-3); flex: none; }
.search input { border: none; outline: none; background: none; color: var(--text); font-size: 13px; width: 100%; font-family: inherit; }
.selwrap { position: relative; display: inline-flex; }
select.sel {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--text-2);
  font-size: 13px; font-family: inherit; padding: 6px 28px 6px 10px; min-height: 32px; cursor: pointer;
}
.selwrap::after { content: ''; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: translateY(-70%) rotate(45deg); pointer-events: none; }

/* List */
.list { display: flex; flex-direction: column; }
.card { display: block; padding: 15px 10px; margin: 0 -10px; border-bottom: 1px solid var(--border); color: var(--text); border-radius: var(--r); transition: background .12s; }
.card:hover { background: var(--surface-2); }
.card:hover .name { color: var(--accent); }
.ch { display: flex; align-items: baseline; gap: 10px; }
.rank { flex: none; width: 22px; font-size: 13px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.rank.top { color: var(--accent); }
.name { font-size: 15px; font-weight: 600; letter-spacing: -.1px; word-break: normal; overflow-wrap: anywhere; transition: color .15s; }
.name .owner { color: var(--text-3); font-weight: 400; }
.score { margin-left: auto; flex: none; font-size: 13px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.desc { font-size: 13.5px; color: var(--text-2); margin: 5px 0 7px 32px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-left: 32px; font-size: 12.5px; color: var(--text-3); }
.meta .m { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.meta svg { width: 12px; height: 12px; opacity: .85; }
.meta .up { color: var(--good); font-weight: 600; }
/* 掉星（主动取消 star / 被刷量回落）是中性事实，用灰色而非绿色，避免误读为"增长" */
.meta .down { color: var(--text-3); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tag { border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 11.5px; color: var(--text-3); }
.tag.new { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.tag.qc { border-color: transparent; background: var(--good-soft); color: var(--good); }
.tag.lic { border-color: transparent; background: var(--good-soft); color: var(--good); font-weight: 600; font-variant-numeric: tabular-nums; }
.tag.off { border-color: transparent; background: var(--accent); color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.tag.topic { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.sp { flex: 1; }

/* States */
.more { text-align: center; margin: 26px 0 0; }
.empty { text-align: center; padding: 56px 20px; color: var(--text-3); font-size: 13.5px; }
.skel { height: 74px; border-bottom: 1px solid var(--border); animation: pl 1.4s ease-in-out infinite; }
@keyframes pl { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  background: var(--text); color: var(--bg); font-size: 13px;
  padding: 10px 18px; border-radius: var(--r); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 200; max-width: calc(100vw - 40px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #d33; color: #fff; }

footer { margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12px; line-height: 1.7; }
footer .fl { display: flex; gap: 6px 20px; flex-wrap: wrap; align-items: baseline; }
footer .fl-brand { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-right: auto; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .wrap { padding: 0 16px 48px; }
  .top { padding: 26px 0 16px; align-items: flex-start; }
  .top h1 { font-size: 18px; }
  .top .btn { padding: 8px 12px; }
  .stats { gap: 20px 26px; padding-bottom: 18px; }
  .stats .n { font-size: 17px; }
  .stat-src { margin-left: 0; text-align: left; }
  .stat-src .n { font-size: 12px; }
  .filters { gap: 10px 12px; padding: 12px 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .filterrow { flex-wrap: wrap; align-items: center; gap: 8px; }
  .filterrow + .filterrow { margin-top: 8px; }
  .flabel { width: auto; text-align: left; font-size: 11px; flex: none; }
  /* 移动端：chip 行独占一行可横滑，日期选择器与提示另起一行 */
  .filterrow > .chips { flex-basis: 100%; order: 2; }
  .filterrow > .flabel { order: 1; }
  .filterrow > .daterange { order: 3; flex-basis: 100%; }
  .filterrow > .hint { order: 4; flex-basis: 100%; }
  /* 横滑提示：右边缘渐隐，提示右侧还有内容 */
  #qualChips, #dateChips, #snapChips { position: relative; transition: opacity .2s; }
  #qualChips.atend::after, #dateChips.atend::after, #snapChips.atend::after { opacity: 0; }
  #qualChips::after, #dateChips::after, #snapChips::after {
    content: ''; position: absolute; right: 0; top: 0; bottom: 2px; width: 26px;
    pointer-events: none; border-radius: 0 6px 6px 0; transition: opacity .2s;
    background: linear-gradient(to right, rgba(0,0,0,0), var(--bg) 78%);
  }
  .daterange { width: 100%; }
  .daterange input { flex: 1; min-width: 0; }
  .search { max-width: none; }
  .card { padding: 13px 8px; margin: 0 -8px; }
  .desc, .meta { margin-left: 32px; }
  footer .fl { flex-direction: column; gap: 6px; }
}
