:root {
  --primary: #2E7CF6;
  --primary-light: #EAF2FF;
  --bg: #F4F7FB;
  --card: #FFFFFF;
  --text: #1B2733;
  --text-sub: #7A8798;
  --border: #E6ECF3;
  --shadow: 0 2px 10px rgba(31, 67, 121, 0.06);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(var(--safe-top) + 16px) 16px 12px;
  background: linear-gradient(145deg, #2E7CF6 0%, #5B9BF8 100%);
  color: #fff;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 4px 18px rgba(46, 124, 246, 0.25);
}

.topbar-inner { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 12px;
  font-size: 20px; font-weight: 700;
}
.brand-text h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: 0.5px; }
.brand-text p { margin: 2px 0 0; font-size: 11px; opacity: 0.82; }

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  color: #fff; cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,0.3); }
.icon-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-wrap { position: relative; margin-top: 14px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9AA9BB; }
#search {
  width: 100%; height: 38px;
  padding: 0 12px 0 38px;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 12px;
  background: rgba(255,255,255,0.92);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
#search::placeholder { color: #9AA9BB; }

.sync-status {
  margin-top: 10px; padding: 6px 10px;
  font-size: 11px; line-height: 1.5;
  background: rgba(255,255,255,0.18);
  border-radius: 8px;
}
.sync-status.error { background: rgba(235,87,87,0.28); }

.main { flex: 1; padding: 18px 16px 24px; }
.group { margin-bottom: 22px; }
.group-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 2px 12px; font-size: 15px; font-weight: 700;
}
.group-title .dot { width: 4px; height: 16px; border-radius: 2px; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.app-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.app-card:active { transform: scale(0.96); box-shadow: none; }
.app-icon {
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border-radius: 14px;
  color: #fff; font-size: 20px; font-weight: 700;
}
.app-name { margin-top: 10px; font-size: 13px; font-weight: 600; text-align: center; line-height: 1.3; }
.app-desc {
  margin-top: 3px; font-size: 10px; color: var(--text-sub); text-align: center; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.empty { padding: 48px 16px; text-align: center; color: var(--text-sub); font-size: 14px; }

.footer { padding: 0 16px calc(var(--safe-bottom) + 16px); text-align: center; font-size: 11px; color: var(--text-sub); }

.loading {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); color: var(--text-sub); font-size: 13px;
}
.loading.hidden { display: none; }
.spinner {
  width: 34px; height: 34px; margin-bottom: 12px;
  border: 3px solid var(--primary-light); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
