:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e3e8f0;
  --line-2: #eef2f8;
  --bg: #f5f7fb;
  --card: #ffffff;
  --accent: #4f46e5;
  --accent-2: #2563eb;
  --ok: #059669;
  --warn: #b45309;
  --danger: #dc2626;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 6px 24px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -24px rgba(15, 23, 42, .28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* 关键：带 display 规则的元素必须让 hidden 属性优先 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(79, 70, 229, .10), transparent 62%),
    radial-gradient(760px 380px at 92% 0%, rgba(37, 99, 235, .08), transparent 60%);
  z-index: 0;
}

.wrap { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; font-size: inherit; cursor: pointer; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 66px; gap: 16px; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .8);
}
.logo svg { width: 21px; height: 21px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15.5px; letter-spacing: .2px; }
.brand-text span { font-size: 12px; color: var(--muted); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.chip {
  font-size: 12px; color: var(--muted);
  background: #fff; border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px;
  white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: #cdece0; background: #f1fbf6; }
.chip.bad { color: var(--danger); border-color: #f8d4d4; background: #fdf3f3; }
.gh-link { font-size: 13px; color: var(--muted); }
.gh-link:hover { color: var(--accent); }

/* ---------------- Hero ---------------- */
main.wrap { flex: 1 0 auto; position: relative; z-index: 1; padding-bottom: 72px; }

.hero { padding: 52px 0 26px; text-align: center; }
.hero h2 {
  margin: 0 0 10px;
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.28;
  letter-spacing: -.4px;
  font-weight: 700;
}
.hero-sub { margin: 0 auto 26px; max-width: 660px; color: var(--muted); font-size: 14.5px; }
.hero-sub b { color: var(--ink-2); }

.searchbar {
  display: flex; gap: 10px; align-items: stretch;
  max-width: 800px; margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, border-color .2s;
}
.searchbar:focus-within { border-color: #c7d2fe; box-shadow: 0 10px 34px -16px rgba(79, 70, 229, .45); }
.field { position: relative; flex: 1; display: flex; align-items: center; }
.field .ico { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted-2); pointer-events: none; }
.field input {
  width: 100%; height: 46px;
  padding: 0 14px 0 38px;
  border: 0; outline: 0; background: transparent;
  font-size: 15px; color: var(--ink);
}
.field input::placeholder { color: var(--muted-2); }
.searchbar select {
  height: 46px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 11px;
  background: #fbfcfe; color: var(--ink-2); font-size: 14px;
  outline: 0;
}
.searchbar button[type=submit] {
  height: 46px; padding: 0 26px;
  border: 0; border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; font-size: 15px;
  box-shadow: 0 8px 20px -12px rgba(79, 70, 229, .9);
  transition: transform .12s ease, filter .2s;
}
.searchbar button[type=submit]:hover { filter: brightness(1.05); }
.searchbar button[type=submit]:active { transform: translateY(1px); }
.searchbar button[type=submit][disabled] { opacity: .6; cursor: progress; }

.hints { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; font-size: 13px; color: var(--muted); }
.hints button {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 4px 11px; border-radius: 999px; font-size: 12.5px;
  transition: all .15s;
}
.hints button:hover { border-color: #c7d2fe; color: var(--accent); background: #f7f8ff; }

/* ---------------- 结果区 ---------------- */
.result-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 8px 0 18px; flex-wrap: wrap;
}
.result-meta { font-size: 13px; color: var(--muted); }
.result-meta b { color: var(--ink); }
.pager { display: flex; gap: 6px; }
.pager button {
  min-width: 34px; height: 32px; padding: 0 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 9px; font-size: 13px;
}
.pager button[disabled] { opacity: .45; cursor: not-allowed; }
.pager button:not([disabled]):hover { border-color: #c7d2fe; color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .16s ease, box-shadow .2s ease, border-color .2s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d5dced; }

.card-top { display: flex; gap: 11px; align-items: flex-start; }
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: var(--av, #4f46e5);
  letter-spacing: -.5px;
  user-select: none;
}
.card-title { min-width: 0; }
.repo-name { display: block; font-weight: 600; font-size: 15px; color: var(--ink); line-height: 1.35; word-break: break-all; }
.card:hover .repo-name { color: var(--accent); }
.card:focus-visible { outline: 2px solid #c7d2fe; outline-offset: 2px; }
.card-title .owner { color: var(--muted); font-weight: 400; }
.card-title .sub { font-size: 12px; color: var(--muted-2); margin-top: 2px; }

.card-desc {
  font-size: 13.5px; color: var(--ink-2); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 44px;
}
.card-desc.empty { color: var(--muted-2); font-style: italic; }

.card-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--muted); }
.card-meta .m { display: inline-flex; align-items: center; gap: 4px; }
.card-meta svg { width: 14px; height: 14px; opacity: .75; }
.lang-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #94a3b8); display: inline-block; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11.5px; color: var(--accent);
  background: #f3f4ff; border: 1px solid #e4e6ff;
  padding: 2px 8px; border-radius: 6px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }

.btn {
  height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 6px 16px -10px rgba(79,70,229,.9); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: #c7d2fe; color: var(--accent); background: #f8f9ff; }
.btn.sm { height: 30px; font-size: 12.5px; padding: 0 10px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------------- 空状态 / 骨架 ---------------- */
.state { padding: 26px 0; }
.state-card {
  border: 1px dashed #d8dfeb; border-radius: var(--radius);
  padding: 46px 24px; text-align: center; color: var(--muted);
  background: rgba(255,255,255,.55);
}
.state-card h3 { margin: 0 0 8px; font-size: 16px; color: var(--ink-2); font-weight: 600; }
.state-card p { margin: 0; font-size: 13.5px; }
.state-card code { font-family: var(--mono); font-size: 12.5px; background: #eef2f9; padding: 1px 6px; border-radius: 5px; color: var(--ink-2); }
.state.error .state-card { border-color: #f6cfcf; background: #fdf6f6; color: #9f1239; }

.skeleton { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.sk-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eef2f8 25%, #f7f9fc 37%, #eef2f8 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; margin-bottom: 10px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------------- 站内详情页 ---------------- */
body.detail-open { overflow: hidden; }

.detail {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: fadeUp .18s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.detail-bar {
  position: sticky; top: 0; z-index: 3;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.detail-bar-inner { height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.back {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px 0 8px;
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  color: var(--ink-2); font-size: 13.5px;
}
.back:hover { border-color: #c7d2fe; color: var(--accent); }
.back svg { width: 16px; height: 16px; }

.detail-wrap { padding: 26px 0 80px; max-width: 900px; }

.detail-head { display: flex; gap: 16px; align-items: flex-start; }
.avatar.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 22px; }
.detail-title { min-width: 0; flex: 1; }
.detail-title h2 { margin: 2px 0 8px; font-size: clamp(20px, 2.4vw, 26px); line-height: 1.3; word-break: break-word; font-weight: 700; }
.detail-title h2 .owner { color: var(--muted); font-weight: 400; }
.detail-desc { margin: 0 0 10px; color: var(--ink-2); font-size: 14px; }

.tabs { display: flex; gap: 4px; margin: 22px 0 0; border-bottom: 1px solid var(--line); }
.tabs button {
  position: relative; height: 40px; padding: 0 16px;
  border: 0; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink-2); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .badge { margin-left: 6px; font-size: 11.5px; color: var(--muted-2); }
.tabs button.on .badge { color: var(--accent); }

.pane { padding-top: 20px; }
.pane-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.pane-tools input {
  flex: 1; height: 36px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 9px; outline: 0; font-size: 13.5px; background: #fff; color: var(--ink);
}
.pane-tools input:focus { border-color: #c7d2fe; }
.pane-tip { font-size: 12px; color: var(--muted-2); flex: none; }

.file-list { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px;
  font-size: 13px; cursor: pointer;
  border: 1px solid transparent;
}
.file-row:hover { background: #f7f9ff; border-color: #e8ecff; }
.file-row .path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }
.file-row .size { font-size: 11.5px; color: var(--muted-2); flex: none; }
.file-row .dl { font-size: 12px; color: var(--accent); flex: none; opacity: 0; transition: opacity .15s; }
.file-row:hover .dl { opacity: 1; }

.readme-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; padding: 34px 0; justify-content: center; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #dbe2ee; border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.readme-empty { text-align: center; color: var(--muted); padding: 52px 20px; }
.readme-empty h3 { margin: 0 0 8px; font-size: 16px; color: var(--ink-2); font-weight: 600; }
.readme-empty p { margin: 0 0 14px; font-size: 13.5px; }
.readme-tip { font-size: 12.5px; color: var(--warn); background: #fffbeb; border: 1px solid #fde68a; padding: 8px 12px; border-radius: 8px; }
.md-raw { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }

/* Markdown 正文排版 */
.markdown {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 26px 30px;
  font-size: 14.5px; line-height: 1.78; color: var(--ink-2);
  overflow-wrap: break-word;
}
.markdown > *:first-child { margin-top: 0; }
.markdown > *:last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 {
  color: var(--ink); line-height: 1.35; margin: 1.5em 0 .6em; font-weight: 650;
}
.markdown h1 { font-size: 24px; padding-bottom: .28em; border-bottom: 1px solid var(--line-2); }
.markdown h2 { font-size: 20px; padding-bottom: .28em; border-bottom: 1px solid var(--line-2); }
.markdown h3 { font-size: 17px; }
.markdown h4 { font-size: 15px; }
.markdown p { margin: .8em 0; }
.markdown a { color: var(--accent); }
.markdown ul, .markdown ol { padding-left: 1.6em; margin: .8em 0; }
.markdown li { margin: .3em 0; }
.markdown li > p { margin: .3em 0; }
.markdown code {
  font-family: var(--mono); font-size: .88em;
  background: #f1f4f9; padding: .15em .4em; border-radius: 5px; color: #b4295b;
}
.markdown pre {
  background: #0f172a; color: #e2e8f0;
  padding: 14px 16px; border-radius: 10px;
  overflow-x: auto; font-size: 13px; line-height: 1.6;
}
.markdown pre code { background: transparent; color: inherit; padding: 0; font-size: 13px; }
.markdown blockquote {
  margin: .9em 0; padding: .3em 1em;
  border-left: 3px solid #c7d2fe; color: var(--muted); background: #f8fafc;
}
.markdown img { max-width: 100%; height: auto; border-radius: 8px; vertical-align: middle; }
.markdown img.broken { display: none; }
.markdown table { border-collapse: collapse; margin: 1em 0; font-size: 13.5px; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.markdown th { background: #f7f9fc; font-weight: 600; color: var(--ink); }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.markdown details { margin: .8em 0; }
.markdown summary { cursor: pointer; color: var(--ink); }
.markdown input[type=checkbox] { margin-right: 6px; vertical-align: middle; }

/* ---------------- 任务托盘 ---------------- */
.dock {
  position: fixed; z-index: 35;
  right: 20px; bottom: 20px;
  width: min(340px, calc(100% - 32px));
  display: flex; flex-direction: column; gap: 10px;
}
.task {
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
  box-shadow: var(--shadow);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.task-title { font-size: 13px; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.task-title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; font-weight: 500; }
.task-sub { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; }
.progress { height: 4px; border-radius: 999px; background: #eef2f8; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s ease; }
/* 未知总大小时（整包 ZIP 走 chunked，没有 Content-Length）用不定长动画 */
.progress.indeterminate i { width: 38% !important; animation: slideBar 1.25s ease-in-out infinite; }
@keyframes slideBar { 0% { transform: translateX(-110%); } 100% { transform: translateX(295%); } }
.task.ready .progress i { background: linear-gradient(90deg, #10b981, #059669); }
.task.failed .progress i { background: var(--danger); }
.task-actions { display: flex; gap: 8px; margin-top: 10px; }
.task-actions .btn { flex: 1; }
.task .err { color: var(--danger); font-size: 12px; margin-top: 4px; word-break: break-word; }
.task .close { border: 0; background: transparent; color: var(--muted-2); font-size: 16px; line-height: 1; padding: 0 2px; }
.task .close:hover { color: var(--ink); }

/* ---------------- 轻提示 ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translate(-50%, 12px);
  z-index: 90;
  max-width: min(560px, calc(100% - 32px));
  padding: 11px 18px;
  border-radius: 11px;
  background: #111827; color: #f8fafc;
  font-size: 13.5px; line-height: 1.5;
  box-shadow: 0 18px 40px -18px rgba(15, 23, 42, .6);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: #064e3b; }
.toast.bad { background: #7f1d1d; }

/* ---------------- 页脚 ---------------- */
.footer {
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  padding: 16px 0; font-size: 12.5px; color: var(--muted);
  position: relative; z-index: 1;
}
.footer .wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.footer b { color: var(--ink-2); }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-2); }

@media (max-width: 720px) {
  .wrap { width: calc(100% - 28px); }
  .hero { padding: 34px 0 18px; }
  .searchbar { flex-wrap: wrap; }
  .field { flex-basis: 100%; }
  .searchbar select { flex: 1; }
  .searchbar button[type=submit] { flex: 1; }
  .grid { grid-template-columns: 1fr; }
  .topbar-right .chip { display: none; }
  .dock { right: 10px; left: 10px; width: auto; bottom: 10px; }
  .detail-wrap { padding: 18px 0 80px; }
  .detail-head { gap: 12px; }
  .avatar.lg { width: 42px; height: 42px; font-size: 18px; border-radius: 12px; }
  .markdown { padding: 18px 16px; font-size: 14px; }
  .detail-bar .btn.sm { padding: 0 10px; font-size: 12.5px; }
}
