/* ========== 设计变量 ========== */
:root {
  --font: "DM Sans", "Noto Sans SC", system-ui, sans-serif;
  --sidebar-w: 220px;
  --topbar-h: 52px;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-fab: 0 4px 16px rgba(15, 23, 42, 0.18);

  --bg: #f7f8fa;
  --bg-grid: rgba(15, 23, 42, 0.07);
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #111827;
  --text-2: #374151;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --topbar: #334155;
  --topbar-text: #e2e8f0;
  --hero-from: #0f172a;
  --hero-to: #1e3a5f;
  --sidebar-bg: #ffffff;
  --sidebar-text: #111827;
  --sidebar-muted: #4b5563;
  --sidebar-active: #f3f4f6;
  --sidebar-active-text: #111827;
  --card-hover: #f9fafb;
}

html.dark {
  --bg: #0b1220;
  --bg-grid: rgba(71, 85, 105, 0.25);
  --surface: #151d2e;
  --surface-2: #1a2438;
  --text: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --border: #243044;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.12);
  --topbar: #0f172a;
  --topbar-text: #cbd5e1;
  --hero-from: #020617;
  --hero-to: #0c1a32;
  --sidebar-active: #1e293b;
  --sidebar-active-text: #93c5fd;
  --sidebar-bg: #151d2e;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #94a3b8;
  --card-hover: #1e293b;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25), 0 4px 14px rgba(0, 0, 0, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button,
input {
  font: inherit;
}

code {
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ========== 布局 ========== */
.app {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--border);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f97316, #ea580c);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

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

.brand-text strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--sidebar-text);
}

.brand-text span {
  font-size: 11px;
  color: var(--sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--sidebar-active);
  color: var(--sidebar-text);
}

.nav-item.is-active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.9;
  color: var(--sidebar-text);
}

.nav-item .chev {
  margin-left: auto;
  opacity: 0.35;
  color: var(--sidebar-muted);
}

.sidebar-foot {
  padding: 12px 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.foot-link,
.foot-btn {
  display: block;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--sidebar-muted);
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: color 0.15s, background 0.15s;
}

.foot-link:hover,
.foot-btn:hover {
  color: var(--sidebar-text);
  background: var(--sidebar-active);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ========== 顶栏 ========== */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--topbar);
  color: var(--topbar-text);
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--topbar-text);
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s, background 0.15s;
}

.top-link:hover,
.top-link.is-active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.topbar-filter {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 160px;
  max-width: min(360px, 42%);
  flex: 1;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--topbar-text);
  transition: background 0.15s, border-color 0.15s;
}

.topbar-filter:focus-within {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
}

.topbar-filter-icon {
  flex-shrink: 0;
  opacity: 0.65;
}

.topbar-filter-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #f8fafc;
  font-size: 13px;
  padding: 0;
}

.topbar-filter-input::placeholder {
  color: rgba(226, 232, 240, 0.55);
}

.topbar-filter-input::-webkit-search-cancel-button {
  cursor: pointer;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

#btn-menu {
  display: none;
  color: var(--topbar-text);
}

/* ========== 滚动区：附图格子白底 ========== */
.scroll {
  flex: 1;
  overflow-y: auto;
  background-color: #f7f8fa;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
}

html.dark .scroll {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ========== 英雄搜索 ========== */
.hero {
  position: relative;
  padding: 36px 24px 40px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  color: #e2e8f0;
}

.hero-bg {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background:
    radial-gradient(ellipse 80% 60% at 70% 40%, rgba(56, 189, 248, 0.25), transparent 60%),
    radial-gradient(ellipse 50% 80% at 20% 80%, rgba(99, 102, 241, 0.2), transparent 55%);
  pointer-events: none;
}

.hero-bg::after {
  content: "";
  position: absolute;
  right: 8%;
  top: 10%;
  width: min(380px, 48vw);
  height: 120%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 400' fill='none'%3E%3Cpath d='M60 0c40 40 40 80 0 120s-40 80 0 120 40 80 0 120' stroke='%237dd3fc' stroke-width='1.2' opacity='0.45'/%3E%3Cpath d='M140 0c-40 40-40 80 0 120s40 80 0 120-40 80 0 120' stroke='%23a5b4fc' stroke-width='1.2' opacity='0.4'/%3E%3Ccircle cx='100' cy='60' r='5' fill='%237dd3fc' opacity='0.5'/%3E%3Ccircle cx='100' cy='140' r='5' fill='%23a5b4fc' opacity='0.5'/%3E%3Ccircle cx='100' cy='220' r='5' fill='%237dd3fc' opacity='0.5'/%3E%3Ccircle cx='100' cy='300' r='5' fill='%23a5b4fc' opacity='0.5'/%3E%3C/svg%3E")
    right center / contain no-repeat;
  opacity: 0.7;
  animation: helix-drift 18s ease-in-out infinite alternate;
}

@keyframes helix-drift {
  from { transform: translateY(-8px) rotate(-2deg); }
  to { transform: translateY(12px) rotate(2deg); }
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.search-form {
  width: 100%;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.search-form:focus-within {
  transform: translateY(-1px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 14px 22px;
  font-size: 15px;
  color: #1e293b;
  background: transparent;
  min-width: 0;
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-go {
  width: 48px;
  height: 48px;
  margin: 4px;
  border: none;
  border-radius: 50%;
  background: #1e293b;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}

.search-go:hover {
  background: #0f172a;
  transform: scale(1.04);
}

.engine-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 20px;
}

.engine-tab {
  border: none;
  background: transparent;
  color: rgba(226, 232, 240, 0.65);
  font-size: 13px;
  padding: 4px 2px 6px;
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}

.engine-tab:hover {
  color: #fff;
}

.engine-tab.is-active {
  color: #fff;
  font-weight: 600;
}

.engine-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 1px;
  background: #38bdf8;
}

/* ========== 内容卡片 ========== */
.content {
  padding: 28px 28px 80px;
  max-width: 1280px;
  margin: 0 auto;
  background: transparent;
}

.section {
  margin-bottom: 36px;
  scroll-margin-top: 24px;
  animation: section-in 0.45s ease both;
  background: transparent;
}

.section:nth-child(1) { animation-delay: 0.05s; }
.section:nth-child(2) { animation-delay: 0.1s; }
.section:nth-child(3) { animation-delay: 0.15s; }
.section:nth-child(4) { animation-delay: 0.2s; }
.section:nth-child(5) { animation-delay: 0.25s; }

@keyframes section-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

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

.link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s, background 0.18s;
  min-height: 64px;
}

.link-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  background: var(--card-hover);
}

.link-card:hover .card-arrow {
  opacity: 0.7;
  transform: translateX(2px);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.card-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.card-icon .fallback {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
}

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

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.card-arrow {
  flex-shrink: 0;
  opacity: 0;
  color: var(--text-3);
  transition: opacity 0.18s, transform 0.18s;
}

.page-foot {
  text-align: center;
  padding: 8px 24px 40px;
  color: var(--text-3);
  font-size: 12px;
}

.page-foot p {
  margin: 0;
}

/* ========== FAB ========== */
.fabs {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fab {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-fab);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.18s, background 0.18s, color 0.18s;
}

.fab:hover {
  transform: translateY(-2px) scale(1.04);
  color: var(--accent);
}

html.dark .icon-moon { display: none; }
html.dark .icon-sun { display: block !important; }
html:not(.dark) .icon-sun { display: none; }

/* ========== 弹层 ========== */
.modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 32px);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
}

.modal-card {
  width: min(440px, 100%);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-card header h2 {
  margin: 0;
  font-size: 16px;
}

.modal-card .icon-btn {
  color: var(--text-2);
  font-size: 22px;
  line-height: 1;
}

.modal-card .icon-btn:hover {
  background: var(--surface-2);
}

.modal-body {
  padding: 16px 18px 20px;
  font-size: 14px;
  color: var(--text-2);
}

.modal-body p {
  margin: 0 0 12px;
}

.modal-body ul {
  margin: 0 0 12px;
  padding-left: 1.2em;
}

.modal-body li {
  margin-bottom: 4px;
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-105%);
  }

  .sidebar.is-open {
    transform: none;
  }

  .main {
    margin-left: 0;
  }

  #btn-menu {
    display: inline-grid;
  }

  .topbar-filter {
    max-width: none;
    min-width: 0;
    flex: 1;
  }

  .content {
    padding: 20px 16px 100px;
  }

  .hero {
    padding: 28px 16px 32px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 520px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .engine-tabs {
    gap: 4px 14px;
  }
}

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