/* ===== 基础变量 ===== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #14161a;
  --text-2: #5b6472;
  --text-3: #8b94a3;
  --border: #e4e7ec;
  --border-strong: #d3d8e0;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 8px 24px -8px rgba(16, 24, 40, 0.16);
  --radius: 14px;
  --maxw: 1180px;
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #0e1013;
  --surface: #171a20;
  --surface-2: #1e222a;
  --text: #e9ecf1;
  --text-2: #9aa4b2;
  --text-3: #6f7887;
  --border: #272c35;
  --border-strong: #343b47;
  --accent: #8b93f8;
  --accent-soft: #1e2136;
  --danger: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* 注意：body 不能写 height:100%，否则高度被锁成一屏，
   内部 position:sticky 的顶栏滚一屏后就会失效 */
html { height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

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

/* ===== 顶栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  /* 用不透明底色而不是毛玻璃：避免下方卡片透过吸顶栏显出来 */
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.2px;
  flex: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  box-shadow: 0 3px 10px -3px rgba(79, 70, 229, 0.6);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  line-height: 1.25;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  line-height: 1.35;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub:empty { display: none; }

.search {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
}

.search svg {
  position: absolute;
  left: 13px;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 38px;
  padding: 0 46px 0 37px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.search input::placeholder { color: var(--text-3); }

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.search kbd {
  position: absolute;
  right: 10px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  pointer-events: none;
}

.search input:focus ~ kbd { opacity: 0; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.icon-btn svg { width: 17px; height: 17px; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

/* ===== 分类条 ===== */
.catbar {
  position: sticky;
  top: var(--topbar-h, 64px);
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* 放得下就一行，放不下自动换行 */
.catbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  max-width: var(--maxw);
  margin: 0 auto;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.chip:hover { background: var(--surface-2); color: var(--text); }

.chip.active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.chip .count {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 400;
}

/* ===== 内容区 ===== */
main.wrap { padding-top: 26px; padding-bottom: 72px; }

.section { margin-bottom: 34px; scroll-margin-top: calc(var(--topbar-h, 64px) + var(--catbar-h, 52px) + 10px); }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 13px;
}

.section-head h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.1px;
}

.section-head .line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-head .num {
  font-size: 12px;
  color: var(--text-3);
}

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

.card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  min-width: 0;
}

.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow-md);
}

.card:active { transform: translateY(0); }

/* 键盘选中的卡片 */
.card.is-focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow-md);
  transform: translateY(-2px);
}

.avatar {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 650;
  font-size: 15px;
  overflow: hidden;
  user-select: none;
  background: linear-gradient(135deg, var(--a1, #6366f1), var(--a2, #4338ca));
}

.avatar-letter { line-height: 1; }

/* 图标加载成功后去掉渐变色底，避免从图标边缘/圆角透出底色 */
.avatar.has-icon { background: none; }
.avatar.has-icon .avatar-letter { opacity: 0; }

/* 暗色模式下深色 logo（如 GitHub 的黑色图标）会看不清，垫一层浅色底 */
[data-theme='dark'] .avatar.has-icon { background: #f2f4f7; }
[data-theme='dark'] .avatar img { padding: 3px; }

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.avatar img.is-loaded { opacity: 1; }

.card-body { min-width: 0; flex: 1; }

.card-title {
  font-size: 13.8px;
  font-weight: 600;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc {
  font-size: 12.2px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.card-go {
  flex: none;
  color: var(--text-3);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.16s, transform 0.16s;
}

.card:hover .card-go { opacity: 1; transform: translateX(0); }

mark {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* ===== 空状态 / 提示 ===== */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-3);
}

.empty .big { font-size: 30px; margin-bottom: 10px; }

.empty a { color: var(--accent); font-weight: 600; }

.notice {
  margin: 40px auto;
  max-width: 620px;
  padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-2);
}

.notice b { color: var(--danger); }

.notice code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ===== 页脚 ===== */
footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 34px;
  color: var(--text-3);
  font-size: 12.5px;
  text-align: center;
}

/* ===== 回到顶部 ===== */
.to-top {
  position: fixed;
  right: 24px;
  bottom: 28px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: 35;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.16s ease, border-color 0.16s ease;
}

.to-top svg { width: 17px; height: 17px; }
.to-top:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

.to-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ===== 骨架屏 ===== */
.skeleton-card {
  height: 63px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ===== 响应式 ===== */
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .catbar-inner { padding: 10px 16px; }
  .topbar-inner { height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; row-gap: 9px; }
  .search { order: 3; flex-basis: 100%; }
  .brand-sub { display: none; }
  .chip { height: 30px; padding: 0 10px; font-size: 12.5px; }
  .catbar-inner { gap: 6px; padding: 8px 16px; }
  .section { scroll-margin-top: calc(var(--topbar-h, 100px) + var(--catbar-h, 110px) + 10px); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 9px; }
  .card { padding: 10px; gap: 9px; }
  .avatar { width: 34px; height: 34px; border-radius: 9px; font-size: 14px; }
  .ghost-btn span { display: none; }
  .ghost-btn { padding: 0 10px; }
}
