:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1f2329;
  --muted: #5f6670;
  --faint: #8f959e;
  --border: #e4e6eb;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --up: #16a34a;
  --up-soft: rgba(22, 163, 74, .12);
  --gold: #f59e0b;
  --warn-bg: #fff7e6;
  --warn-text: #ad6800;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .05);
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --panel: #171a20;
    --text: #e6e8eb;
    --muted: #a1a7b0;
    --faint: #6f7680;
    --border: #282c34;
    --accent: #6ea8fe;
    --accent-soft: #1b2740;
    --up: #4ade80;
    --up-soft: rgba(74, 222, 128, .14);
    --warn-bg: #3a2c12;
    --warn-text: #f5c26b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 1.15rem; margin: 0; }

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

/* ── Tabs ──────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-top: 16px; }
.tab {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); border-bottom: none;
  background: var(--bg); color: var(--muted);
  padding: 8px 20px; border-radius: 10px 10px 0 0;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel); color: var(--text); border-color: var(--border); position: relative; }
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--panel);
}

/* ── Header ─────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; font-weight: 800; letter-spacing: .5px;
}
.brand h1 { margin: 0; font-size: 1.2rem; }
.tagline { margin: 0; color: var(--muted); font-size: .84rem; }
.week-picker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }

select, input[type="search"] {
  font: inherit; color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
  max-width: 100%;
  min-width: 0;
}
select:focus, input[type="search"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Hero：本周看点 + 数据速览 ──────────────────────── */
.hero { margin: 26px 0 8px; display: grid; gap: 14px; }
.hero-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.hero-title h2 { font-size: 1.6rem; letter-spacing: .3px; }
.hero-title .range { color: var(--muted); }

.highlights {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, var(--panel)), var(--panel) 60%);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow);
}
.highlights .eyebrow { color: var(--accent); font-size: .8rem; font-weight: 600; letter-spacing: 1px; }
.highlights .headline { margin: 6px 0 10px; font-size: 1.25rem; font-weight: 700; line-height: 1.45; }
.highlights ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.highlights li::marker { color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); min-width: 0; }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: 2px; line-height: 1.3; }
.stat .value.up { color: var(--up); }
.stat .sub { color: var(--faint); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .sub a { color: inherit; }
.notice { background: var(--warn-bg); color: var(--warn-text); border-radius: 10px; padding: 9px 14px; font-size: .88rem; }

/* ── Podium：前三名 ─────────────────────────────────── */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 22px 0 8px; }
.feature {
  position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.feature:hover { transform: translateY(-2px); border-color: var(--accent); }
.feature.rank-1 { border-top: 4px solid #f5b301; }
.feature.rank-2 { border-top: 4px solid #a3acb9; }
.feature.rank-3 { border-top: 4px solid #cd7f32; }
.feature-head { display: flex; align-items: center; gap: 10px; }
.feature .medal { font-size: 1.7rem; line-height: 1; }
.feature .repo { flex: 1; min-width: 0; }
.feature .repo a { display: block; font-weight: 700; font-size: 1.05rem; color: var(--text); word-break: break-all; }
.feature .repo .owner { color: var(--muted); font-weight: 400; }
.feature .one-liner { margin: 0; font-size: 1.1rem; font-weight: 700; line-height: 1.45; }
.feature .what { margin: 0; color: var(--muted); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.feature .spark-box { margin-top: auto; }
.spark-caption { display: flex; justify-content: space-between; color: var(--faint); font-size: .75rem; margin-bottom: 2px; }
.feature .spark { width: 100%; height: 64px; }

.metrics { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .86rem; color: var(--muted); }
.metrics b { color: var(--text); font-weight: 650; }
.metrics .up { color: var(--up); }

.cat { flex: none; font-size: .76rem; color: var(--muted); border: 1px solid var(--border); padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: .76rem; }
.tag { background: var(--bg); color: var(--muted); padding: 1px 8px; border-radius: 6px; }
.tag.lang { color: var(--text); }
.warn { background: var(--warn-bg); color: var(--warn-text); padding: 6px 10px; border-radius: 8px; font-size: .82rem; }

details.more summary { cursor: pointer; color: var(--accent); font-size: .86rem; user-select: none; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: " ▾"; }
details.more[open] summary::after { content: " ▴"; }

dl.intro { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: .88rem; }
dl.intro dt { color: var(--muted); white-space: nowrap; }
dl.intro dd { margin: 0; }
dl.intro ul { margin: 0; padding-left: 1.1em; }

/* ── List：紧凑列表 ─────────────────────────────────── */
.list-section { margin-top: 30px; }
.list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; justify-content: flex-end; }
.toolbar input[type="search"] { flex: 0 1 280px; min-width: 180px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  font: inherit; font-size: .84rem; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 3px 12px; border-radius: 999px;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .count { opacity: .7; margin-left: 4px; }
.result-count { color: var(--muted); font-size: .84rem; margin: 6px 0 10px; }

.list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row > summary {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 130px 92px 92px 18px; align-items: center; gap: 14px;
  padding: 12px 18px;
}
.row > summary::-webkit-details-marker { display: none; }
.row > summary:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.row[open] > summary { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.row .rank { color: var(--faint); font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
.row .main { min-width: 0; }
.row .title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .title a { font-weight: 650; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .title .owner { color: var(--muted); font-weight: 400; }
.row .line { color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .spark { width: 130px; height: 32px; }
.row .col-num { text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }
.row .col-num small { display: block; color: var(--faint); font-size: .72rem; }
.row .col-num.up { color: var(--up); font-weight: 650; }
.row .chev { color: var(--faint); transition: transform .15s ease; }
.row[open] .chev { transform: rotate(90deg); }
.row-body { padding: 4px 18px 16px 76px; display: grid; gap: 10px; }
.row-body .desc { margin: 0; color: var(--muted); font-size: .88rem; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; margin: 0; }

/* ── Sparkline ─────────────────────────────────────── */
.spark { display: block; overflow: visible; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--accent); opacity: .12; }
.spark-1k { stroke: var(--gold); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.spark-dot { fill: var(--accent); }
.spark-none { color: var(--faint); font-size: .75rem; text-align: center; }

/* ── Continuing ────────────────────────────────────── */
.continuing { margin-top: 36px; }
.continuing h2 { margin-bottom: 12px; }
.continuing h2 small { color: var(--muted); font-weight: 400; font-size: .85rem; margin-left: 6px; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 14px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.site-footer { color: var(--faint); font-size: .8rem; text-align: center; padding-top: 32px; padding-bottom: 40px; }
.site-footer p { margin: 4px 0; }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 960px) {
  .podium { grid-template-columns: 1fr; }
  .row > summary { grid-template-columns: 36px minmax(0, 1fr) 96px 84px 18px; }
  .row .col-stars { display: none; }
  .row .spark { width: 96px; }
}
@media (max-width: 640px) {
  .header-inner { flex-direction: column; align-items: stretch; }
  .week-picker select { flex: 1; }
  .toolbar { justify-content: stretch; }
  .toolbar input[type="search"], .toolbar select { flex: 1 1 100%; }
  .row > summary { grid-template-columns: 30px minmax(0, 1fr) 72px 14px; gap: 10px; padding: 12px; }
  .row .col-spark { display: none; }
  .row-body { padding: 4px 12px 14px 52px; }
  .hero-title h2 { font-size: 1.3rem; }
}
