:root {
  --bg: #eef1f8;
  --bg-grad: linear-gradient(135deg, #4f6ef7 0%, #7a5cf0 55%, #9b5cf0 100%);
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #1f2330;
  --text-soft: #5b6275;
  --text-faint: #9aa1b4;
  --border: #e6e9f2;
  --accent: #4f6ef7;
  --accent-soft: #eef1fe;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.65);
  --shadow: 0 6px 22px rgba(31, 35, 48, 0.08);
  --shadow-hover: 0 16px 38px -12px rgba(31, 35, 48, 0.22);
  --radius: 16px;
}

[data-theme="dark"] {
  --bg: #0e1017;
  --bg-grad: linear-gradient(135deg, #6f86ff 0%, #9a7cff 55%, #c06bff 100%);
  --surface: #171a23;
  --surface-2: #20242f;
  --text: #e8eaf0;
  --text-soft: #aab0c2;
  --text-faint: #717892;
  --border: #2a2f3c;
  --accent: #8a9bff;
  --accent-soft: #232a44;
  --glass: rgba(20, 23, 32, 0.62);
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 18px 42px -12px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

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

/* 动态极光背景 */
body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 14% 18%, rgba(79, 110, 247, 0.20), transparent 60%),
    radial-gradient(38% 32% at 86% 14%, rgba(155, 92, 240, 0.18), transparent 60%),
    radial-gradient(46% 42% at 50% 92%, rgba(79, 110, 247, 0.13), transparent 62%),
    radial-gradient(34% 30% at 78% 76%, rgba(255, 130, 180, 0.12), transparent 60%);
  filter: blur(8px);
  animation: aurora 20s ease-in-out infinite alternate;
}
@keyframes aurora {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(2.5%, -2%, 0) scale(1.08); }
  100% { transform: translate3d(-2.5%, 2.5%, 0) scale(1.04); }
}

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ============ Topbar（玻璃拟态） ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 8px 30px rgba(31, 35, 48, 0.07);
}
.brand-logo {
  justify-self: start;
  position: relative;
  z-index: 1;
  width: 50px; height: 50px;
  border-radius: 15px;
  background: var(--bg-grad);
  display: grid; place-items: center;
  font-size: 25px; font-weight: 800;
  color: #fff;
  box-shadow: 0 8px 20px -6px rgba(79, 110, 247, 0.65), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  transition: transform .25s cubic-bezier(.2,.7,.3,1), box-shadow .25s;
}
.brand-logo:hover { transform: rotate(-6deg) scale(1.07); box-shadow: 0 12px 26px -6px rgba(79, 110, 247, 0.75), inset 0 0 0 1px rgba(255, 255, 255, 0.4); }
.brand-text { justify-self: center; text-align: center; position: relative; z-index: 1; }
.brand-text h1 {
  margin: 0; font-size: 27px; font-weight: 800; letter-spacing: 3px;
  background: var(--bg-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-soft); letter-spacing: 1px; }
.theme-toggle { justify-self: end; }

.search-bar {
  display: flex;
  justify-content: center;
  padding: 20px 26px 6px;
}
.search-wrap {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 13px 22px;
  box-shadow: var(--shadow);
  color: var(--text-soft);
  transition: box-shadow .22s ease, border-color .22s ease, transform .22s ease;
}
.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.16), var(--shadow);
  transform: translateY(-1px);
}
.search-icon { color: var(--accent); flex: 0 0 auto; filter: drop-shadow(0 1px 2px rgba(79,110,247,.25)); }
#search {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#search::placeholder { color: var(--text-faint); }
.search-count {
  font-size: 12px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); padding: 3px 11px; border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto;
}

.theme-toggle {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border: 1px solid var(--glass-border);
  border-radius: 13px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 19px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  position: relative; z-index: 1;
}
.theme-toggle:hover { background: var(--surface-2); transform: scale(1.07) rotate(8deg); box-shadow: var(--shadow); }

/* ============ Layout ============ */
.layout {
  display: grid;
  grid-template-columns: 252px 1fr;
  gap: 0;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
  height: calc(100vh - 84px);
  overflow-y: auto;
  padding: 24px 14px 40px 22px;
}
.sidebar-title {
  font-size: 11px; font-weight: 800; letter-spacing: 2px;
  color: var(--text-faint); text-transform: uppercase;
  margin: 0 0 12px 14px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  margin: 3px 0;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-soft);
  font-weight: 500;
  transition: background 0.16s, color 0.16s, transform 0.16s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-size: 14.5px;
  position: relative;
}
.sidebar-item .cat-ico {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: 15px;
  border-radius: 9px;
  background: var(--surface-2);
  transition: transform .16s, background .16s;
}
.sidebar-item::before {
  content: "";
  position: absolute; left: 4px; top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px; height: 20px; border-radius: 3px;
  background: var(--bg-grad);
  transition: transform .18s ease;
}
.sidebar-item:hover { background: var(--surface-2); color: var(--text); transform: translateX(3px); }
.sidebar-item:hover .cat-ico { transform: scale(1.08); background: var(--accent-soft); }
.sidebar-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sidebar-item.active::before { transform: translateY(-50%) scaleY(1); }
.sidebar-item.active .cat-ico { background: var(--bg-grad); }
.sidebar-item .count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-faint);
  background: var(--surface-2);
  padding: 1px 9px;
  border-radius: 999px;
}
.sidebar-item.active .count { background: var(--accent); color: #fff; }

.content {
  padding: 28px 36px 70px;
  min-height: calc(100vh - 84px);
}

/* ============ Sections ============ */
.section { margin-bottom: 44px; scroll-margin-top: 92px; }
.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.section-head::after {
  content: "";
  position: absolute; left: 0; bottom: -1px;
  width: 64px; height: 2px; border-radius: 2px;
  background: var(--bg-grad);
}
.section-head .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg-grad);
  box-shadow: 0 0 0 4px rgba(79,110,247,.14);
  flex: 0 0 auto;
}
.section-head h2 {
  margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .5px;
  background: var(--bg-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.section-head .badge {
  margin-left: auto;
  font-size: 12px; font-weight: 600;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 12px; border-radius: 999px;
  box-shadow: var(--shadow);
}

.subsection { margin: 22px 0 8px; }
.subsection-head {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-soft);
  padding: 8px 12px;
  border-radius: 10px;
  transition: color .15s, background .15s;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.subsection-head:hover { color: var(--accent); background: var(--surface-2); }
.subsection-head .arrow {
  transition: transform 0.22s; font-size: 11px; color: var(--text-faint);
}
.subsection.collapsed .arrow { transform: rotate(-90deg); }
.subsection.collapsed > .subsection-body { display: none; }
.subsection-head .badge {
  margin-left: auto;
  font-size: 11.5px; font-weight: 600; color: var(--text-faint);
  background: var(--surface-2); padding: 1px 9px; border-radius: 999px;
}

/* ============ Cards ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.2s cubic-bezier(.2,.7,.3,1), box-shadow 0.2s, border-color 0.2s;
  overflow: hidden;
  position: relative;
  animation: cardIn 0.5s cubic-bezier(.2,.7,.3,1) both;
  animation-delay: calc(var(--i, 0) * 16ms);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.card::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--c, transparent);
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
.card::after {
  content: "";
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 0; border-radius: 0 3px 3px 0;
  background: var(--c, var(--accent));
  transition: height 0.24s cubic-bezier(.2,.7,.3,1);
}
.card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--c, var(--accent)) 50%, var(--border));
  box-shadow: 0 18px 40px -12px color-mix(in srgb, var(--c, var(--accent)) 60%, transparent);
}
.card:hover::before { opacity: 0.06; }
.card:hover::after { height: 62%; }
.card > * { position: relative; z-index: 1; }

.card-icon {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-2);
  box-shadow: 0 2px 8px rgba(31,35,48,.12);
}
.card-letter {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(31,35,48,.2), inset 0 1px 0 rgba(255,255,255,.25);
}
.card-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-host {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.card:hover .card-title { color: var(--c, var(--accent)); }

.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 70px 0;
  font-size: 15px;
}
.empty .emo { font-size: 44px; display: block; margin-bottom: 12px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.08)); }

.footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  padding: 22px;
  border-top: 1px solid var(--border);
  letter-spacing: .5px;
}

/* ============ 回到顶部 ============ */
.back-top {
  position: fixed;
  right: 28px; bottom: 28px;
  width: 46px; height: 46px;
  border: none; border-radius: 15px;
  background: var(--bg-grad);
  color: #fff; font-size: 19px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(79,110,247,.4);
  opacity: 0; visibility: hidden;
  transform: translateY(14px) scale(.9);
  transition: opacity .25s, transform .25s, visibility .25s;
  z-index: 30;
}
.back-top.show { opacity: 1; visibility: visible; transform: none; }
.back-top:hover { transform: translateY(-3px) scale(1.06); }

/* ============ Responsive ============ */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 10;
    height: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 16px;
    background: var(--glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--glass-border);
  }
  .sidebar-title { display: none; }
  .sidebar-item { width: auto; margin: 0; }
  .sidebar-item::before { display: none; }
  .sidebar-item .count { display: none; }
  .content { padding: 18px; }
  .topbar { gap: 10px; padding: 12px 16px; }
  .brand-text h1 { font-size: 21px; letter-spacing: 2px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
  .back-top { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .card { animation: none; }
}
