/* ============================================================
   APPs 资源站 · 前台样式
   主题：html[data-theme="light" | "dark"]
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --text: #16181d;
  --text-2: #5b6470;
  --text-3: #8b94a1;
  --line: #e6e8ec;
  --line-soft: #eef0f3;
  --primary: #2563eb;
  --primary-soft: #eff4ff;
  --primary-text: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --tag-bg: #f2f4f7;
  --ok: #0f9d58;
  --warn: #b45309;
  --warn-bg: #fff8e6;
  --radius: 14px;
}

html[data-theme="dark"] {
  --bg: #101216;
  --bg-soft: #171a1f;
  --card: #1a1d23;
  --text: #e9ecf1;
  --text-2: #a3acb9;
  --text-3: #7c8593;
  --line: #2a2f38;
  --line-soft: #23272f;
  --primary: #3b82f6;
  --primary-soft: #1c2740;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, .5);
  --tag-bg: #232831;
  --warn: #f0b429;
  --warn-bg: #2c2412;
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── 顶栏 ───────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 62px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.brand-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--text-3); padding-left: 2px; }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute; left: 12px;
  width: 16px; height: 16px; color: var(--text-3);
  pointer-events: none;
}
#search {
  width: 100%;
  height: 38px;
  padding: 0 66px 0 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}
#search::-webkit-search-cancel-button { cursor: pointer; }
.search-kbd {
  position: absolute; right: 10px;
  font-size: 10.5px; color: var(--text-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--bg);
  pointer-events: none;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--text-2);
  transition: .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }
.icon-btn svg { width: 17px; height: 17px; }
.i-moon { display: none; }
html[data-theme="dark"] .i-sun { display: none; }
html[data-theme="dark"] .i-moon { display: block; }
#menuBtn { display: none; }
.ghost-btn {
  height: 34px; padding: 0 14px;
  display: inline-flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 13px;
  transition: .15s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--text-3); }

/* ───────── Hero 统计带 ───────── */

.hero-band {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--primary) 7%, var(--bg)),
    var(--bg) 92%);
  border-bottom: 1px solid var(--line);
}
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 24px 20px;
}
.hero-title {
  margin: 0;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -.01em;
  line-height: 1.3;
}
.hero-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
}
.hero-stats { display: flex; align-items: center; flex-shrink: 0; }
.stat { text-align: center; min-width: 58px; }
.stat b {
  display: block;
  font-size: 19px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.stat span { font-size: 11.5px; color: var(--text-3); }
.stat + .stat { border-left: 1px solid var(--line); padding-left: 18px; margin-left: 18px; }

/* ───────── 布局 ───────── */

.layout {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  gap: 28px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 24px 60px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding-right: 4px;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.side-title {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.cat-nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--line-soft); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--c, var(--text-3));
  flex-shrink: 0;
}
.nav-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-count { color: var(--primary); }
.nav-item.fav .nav-dot { background: #f59e0b; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-btn {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-2);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  transition: .12s;
}
.tag-btn:hover { border-color: var(--primary); color: var(--primary); }
.tag-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

/* ───────── 工具条 ───────── */

.main { min-width: 0; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.result-count { font-size: 13px; color: var(--text-3); }
.result-count b { color: var(--text); font-size: 15px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 6px 0 9px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
}
.chip button {
  border: 0; background: transparent; color: inherit;
  font-size: 14px; line-height: 1; padding: 0 2px; opacity: .65;
}
.chip button:hover { opacity: 1; }

.toolbar-right { display: flex; align-items: center; gap: 8px; }
.sort-label { font-size: 12.5px; color: var(--text-3); }
.sort-select {
  height: 30px;
  padding: 0 26px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' fill='none' stroke='%238b94a1' stroke-width='1.4' stroke-linecap='round'/></svg>")
    no-repeat right 8px center;
  color: var(--text);
  font-size: 13px;
  appearance: none;
  outline: none;
  cursor: pointer;
}

/* ───────── 卡片网格 ───────── */

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--c, var(--line));
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .18s, transform .18s;
}
.card:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
  border-top-color: var(--c, var(--line));
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.card.open { grid-column: 1 / -1; transform: none; }

.card-head { display: flex; align-items: flex-start; gap: 11px; }

.card-logo {
  position: relative;
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--c, #6b7280) 14%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--c, #6b7280) 22%, transparent);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.logo-letter {
  font-size: 17px;
  font-weight: 700;
  color: var(--c, var(--text-2));
  text-transform: uppercase;
}
.card-logo img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 5px;
  background: var(--card);
}

.card-title-wrap { min-width: 0; flex: 1; }
.card-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.35;
}
.card-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-ver { font-size: 11px; font-weight: 500; color: var(--text-3); flex-shrink: 0; font-style: normal; }
.card-sub {
  display: flex; align-items: center; gap: 6px;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-3);
}
.plat { display: inline-flex; gap: 3px; }
.plat i {
  font-style: normal;
  font-size: 10px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--tag-bg);
  color: var(--text-3);
  line-height: 16px;
}

.cat-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--c) 13%, transparent);
  color: color-mix(in srgb, var(--c) 76%, var(--text));
  white-space: nowrap;
  flex-shrink: 0;
}

.fav-btn {
  border: 0;
  background: transparent;
  font-size: 15px;
  line-height: 1;
  padding: 2px 0 0 2px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform .15s, color .15s;
}
.fav-btn:hover { transform: scale(1.15); color: #f59e0b; }
.fav-btn.on { color: #f59e0b; }

.card-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}

.card-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag-pill {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--tag-bg);
  color: var(--text-2);
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px dashed var(--line-soft);
}
.dl-count { font-size: 11.5px; color: var(--text-3); }

.btn-dl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 12.5px;
  font-weight: 600;
  transition: filter .15s, transform .1s;
}
.btn-dl:hover { filter: brightness(1.08); }
.btn-dl:active { transform: scale(.97); }
.btn-dl[disabled] {
  background: var(--tag-bg);
  color: var(--text-3);
  cursor: not-allowed;
  filter: none;
}
.btn-dl svg { width: 12px; height: 12px; }

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

/* ───────── 骨架屏（加载中） ───────── */

.skel-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.skel {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: var(--line-soft);
}
.skel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 7%, transparent), transparent);
  transform: translateX(-100%);
  animation: skel-shine 1.5s infinite;
}
@keyframes skel-shine {
  to { transform: translateX(100%); }
}
.skel-row { display: flex; align-items: flex-start; gap: 11px; }
.skel-logo { width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.skel-line { height: 12px; }
.skel-line.w60 { width: 60%; }
.skel-line.w40 { width: 40%; }
.skel-line.w92 { width: 92%; }
.skel-line.w75 { width: 75%; }
.skel-foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.skel-count { width: 52px; height: 10px; }
.skel-btn { width: 66px; height: 28px; border-radius: 8px; }

/* ───────── 下载面板 ───────── */

.panel {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: slideDown .16s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.dl-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 9px;
  transition: background .12s;
}
.dl-row:hover { background: var(--bg); }
.dl-row + .dl-row { border-top: 1px solid var(--line-soft); }

.dl-src { display: flex; align-items: center; gap: 6px; min-width: 0; }
.src-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--s, #666); flex-shrink: 0; }
.src-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.src-label {
  font-size: 10.5px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary);
  line-height: 16px;
  white-space: nowrap;
}

.dl-main { min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dl-url {
  font-size: 12px;
  color: var(--text-2);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.dl-url:hover { color: var(--primary); text-decoration: underline; }
.dl-code {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.dl-code b {
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text);
  letter-spacing: .05em;
}

.dl-actions { display: flex; gap: 6px; }
.mini-btn {
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 11.5px;
  transition: .13s;
  white-space: nowrap;
}
.mini-btn:hover { border-color: var(--primary); color: var(--primary); }
.mini-btn.solid {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
  font-weight: 600;
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 8px 2px;
  margin-top: 4px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--text-3);
  flex-wrap: wrap;
}
.panel-foot.warn { color: var(--warn); }
.official-link { color: var(--primary); font-size: 12px; }
.official-link:hover { text-decoration: underline; }

.panel-empty {
  padding: 14px 8px;
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
}
.panel-empty b { color: var(--text-2); }

/* ───────── 空态 ───────── */

.empty { padding: 70px 20px; text-align: center; }
.empty-icon { color: var(--text-3); opacity: .55; margin-bottom: 6px; }
.empty-icon svg { display: block; width: 38px; height: 38px; margin: 0 auto; }
.empty-title { margin: 12px 0 4px; font-size: 15px; font-weight: 600; }
.empty-hint { margin: 0 0 18px; font-size: 13px; color: var(--text-3); }
.btn-primary {
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

/* ───────── 页脚 ───────── */

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
}
.footer b { color: var(--text-2); }

/* ───────── Toast ───────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 20px);
  padding: 9px 18px;
  border-radius: 10px;
  background: rgba(23, 26, 31, .94);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 90;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ───────── 响应式 ───────── */

@media (max-width: 1280px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .layout { grid-template-columns: 190px minmax(0, 1fr); gap: 20px; padding: 20px 18px 50px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-sub { display: none; }
}
@media (max-width: 768px) {
  .topbar { height: 56px; padding: 0 14px; gap: 10px; }
  .hero { padding: 16px 14px 12px; }
  .hero-title { font-size: 16.5px; }
  .hero-stats { gap: 0 14px; }
  .stat { min-width: 50px; }
  .stat b { font-size: 16px; }
  .stat + .stat { padding-left: 14px; margin-left: 14px; }
  .search-kbd { display: none; }
  #search { padding-right: 12px; }
  #menuBtn { display: grid; }
  .ghost-btn { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 14px 14px 40px; }
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    z-index: 35;
    width: 240px;
    height: calc(100vh - 56px);
    max-height: none;
    padding: 16px;
    background: var(--bg-soft);
    border-right: 1px solid var(--line);
    transform: translateX(-102%);
    transition: transform .22s ease;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .card.open { grid-column: auto; }
  .dl-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "src actions" "main main"; row-gap: 6px; }
  .dl-src { grid-area: src; }
  .dl-main { grid-area: main; }
  .dl-actions { grid-area: actions; }
  .footer { padding: 16px 14px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
