:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #14171c;
  --muted: #616b7a;
  --faint: #8b95a3;
  --accent: #2f6df6;
  --accent-soft: #e8f0ff;
  --warn: #a86412;
  --warn-soft: #fdf1e0;
  --ok: #1a7f4b;
  --ok-soft: #e6f6ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .18);
}
html[data-theme="dark"] {
  --bg: #0e1116;
  --panel: #151a21;
  --card: #161b23;
  --line: #262d38;
  --text: #e8ecf2;
  --muted: #9aa5b5;
  --faint: #6f7a89;
  --accent: #6f9bff;
  --accent-soft: #1b2740;
  --warn: #e0a458;
  --warn-soft: #2b2318;
  --ok: #58c48a;
  --ok-soft: #16281f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 20px; align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 3vw, 36px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 14px; align-items: center; min-width: 0; }
.mark {
  width: 44px; height: 44px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 19px; color: #fff;
  background: linear-gradient(140deg, #2f6df6, #7a4df6);
  box-shadow: 0 6px 18px -8px rgba(47, 109, 246, .8);
}
.brand-text { min-width: 0; }
h1 { margin: 0; font-size: 19px; letter-spacing: .2px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.tools { display: flex; gap: 10px; align-items: center; }

.search { position: relative; display: block; }
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; fill: var(--faint);
}
.search input {
  width: clamp(180px, 26vw, 320px);
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--text); font: inherit; font-size: 14px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.ghost {
  padding: 9px 13px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-size: 14px; white-space: nowrap;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 布局 ---------- */
.layout {
  display: grid; grid-template-columns: 258px minmax(0, 1fr);
  gap: 26px; padding: 24px clamp(16px, 3vw, 36px) 8px;
  align-items: start; max-width: 1500px; margin: 0 auto;
}
.panel {
  position: sticky; top: 92px;
  max-height: calc(100vh - 116px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 16px 12px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: 14px; margin-bottom: 6px;
}
.link {
  border: 0; background: none; color: var(--accent);
  font: inherit; font-size: 13px; cursor: pointer; padding: 2px 4px;
}
.link:hover { text-decoration: underline; }

.fgroup { border-top: 1px solid var(--line); padding: 11px 0 9px; }
.fgroup:first-child { border-top: 0; }
.fgroup > h3 {
  margin: 0 0 8px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); letter-spacing: .4px;
  display: flex; justify-content: space-between;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  --c: var(--line);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px 4px 8px;
  border: 1px solid var(--c); border-radius: 999px;
  background: var(--panel); color: var(--muted);
  font-size: 12.5px; line-height: 1.5; cursor: pointer;
  user-select: none; transition: all .12s ease;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip .box {
  width: 13px; height: 13px; border-radius: 4px; flex: none;
  border: 1.5px solid currentColor; display: grid; place-items: center;
  font-size: 10px; line-height: 1;
}
.chip .n { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.chip[aria-pressed="true"] {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600;
}
.chip[aria-pressed="true"] .n { color: var(--accent); opacity: .8; }
.chip[data-zero="true"] { opacity: .42; }
.hint { margin: 10px 0 2px; font-size: 12px; color: var(--faint); }

/* ---------- 结果区 ---------- */
.bar {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.count { margin: 0; font-size: 13.5px; color: var(--muted); }
.count b { color: var(--text); font-size: 15px; }
.bar-tools { display: flex; gap: 10px; }
.sel { font-size: 12.5px; color: var(--faint); display: inline-flex; gap: 6px; align-items: center; }
.sel select {
  padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}

.list { display: flex; flex-direction: column; gap: 22px; }
.sec-title {
  display: flex; align-items: baseline; gap: 10px; margin: 4px 0 2px;
  font-size: 14px; font-weight: 650; color: var(--text);
}
.sec-title span { font-size: 12.5px; font-weight: 400; color: var(--faint); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card {
  display: flex; flex-direction: column; gap: 9px;
  padding: 16px 16px 13px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card-top { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.card h3 { margin: 0; font-size: 15.5px; line-height: 1.45; font-weight: 650; }
.card h3 a { color: inherit; }
.card h3 a:hover { color: var(--accent); text-decoration: none; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; flex: none; }
.badge {
  font-size: 11px; padding: 1.5px 7px; border-radius: 6px; white-space: nowrap;
  border: 1px solid transparent; line-height: 1.7;
}
.badge.private { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge.local { color: var(--faint); background: color-mix(in srgb, var(--faint) 12%, transparent); border-color: var(--line); }
.badge.fork { color: var(--muted); background: color-mix(in srgb, var(--muted) 10%, transparent); border-color: var(--line); }
.badge.snapshot { color: var(--muted); background: color-mix(in srgb, var(--muted) 10%, transparent); border-color: var(--line); }
.badge.archived { color: var(--muted); background: color-mix(in srgb, var(--muted) 10%, transparent); border-color: var(--line); }

.card p {
  margin: 0; color: var(--muted); font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-size: 11.5px; padding: 1px 7px; border-radius: 6px;
  color: var(--muted); background: color-mix(in srgb, var(--muted) 9%, transparent);
}
.tag.d { color: var(--accent); background: var(--accent-soft); }
.meta {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: auto; padding-top: 9px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.open { margin-left: auto; font-size: 12.5px; }

.empty { padding: 60px 0; text-align: center; color: var(--muted); }
.foot {
  max-width: 1500px; margin: 0 auto; padding: 26px clamp(16px, 3vw, 36px) 40px;
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  font-size: 12px; color: var(--faint); border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
  .tools { flex: 1 1 auto; justify-content: flex-end; }
}
@media (max-width: 620px) {
  .top { flex-wrap: wrap; }
  .search input { width: 100%; }
  .search { flex: 1 1 200px; }
}
