/* ========== 基础样式 ========== */
* { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif; transition: background 0.2s; }

/* ========== Logo 亮暗切换 ========== */
.logo a { display: inline-block; position: relative; line-height: 0; }
.logo .logo-light, .logo .logo-dark { display: block; transition: opacity 0.2s ease; }
.logo .logo-dark { position: absolute; top: 0; left: 0; opacity: 0; pointer-events: none; }
.dark .logo .logo-light { opacity: 0; pointer-events: none; }
.dark .logo .logo-dark { opacity: 1; pointer-events: auto; }

/* ========== 导航菜单 ========== */
.nav-menu { display: flex; gap: 6px; align-items: center; background: #60a5fa; border-radius: 12px; padding: 6px 8px; box-shadow: 0 4px 14px rgba(59,130,246,0.18); }
.dark .nav-menu { background: #1e40af; box-shadow: 0 4px 14px rgba(0,0,0,0.35); }
.nav-menu > li { position: relative; list-style: none; }
.nav-menu > li > a { display: block; padding: 8px 18px; border-radius: 8px; font-size: 15px; font-weight: 500; color: #fff; text-decoration: none; transition: all 0.2s; white-space: nowrap; }
.nav-menu > li > a:hover, .nav-menu > li > a.active { background: #2563eb; color: #fff; }
.dark .nav-menu > li > a:hover, .dark .nav-menu > li > a.active { background: #3b82f6; }
.nav-menu .sub-menu { position: absolute; top: 100%; left: 0; min-width: 170px; background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); padding: 6px; opacity: 0; visibility: hidden; transform: translateY(8px); transition: all 0.2s ease; z-index: 100; list-style: none; margin: 6px 0 0 0; }
.dark .nav-menu .sub-menu { background: #1f2937; border-color: #374151; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.nav-menu > li:hover .sub-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.nav-menu .sub-menu li a { display: block; padding: 8px 14px; font-size: 14px; color: #4b5563; text-decoration: none; border-radius: 6px; white-space: nowrap; }
.dark .nav-menu .sub-menu li a { color: #9ca3af; }
.nav-menu .sub-menu li a:hover { background: #eff6ff; color: #2563eb; padding-left: 18px; }
.dark .nav-menu .sub-menu li a:hover { background: #374151; color: #60a5fa; }

/* ========== 顶部右侧按钮 ========== */
.btn-history {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: #60a5fa;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-history:hover {
  background: #2563eb;
}
.dark .btn-history {
  background: #1e40af;
}
.dark .btn-history:hover {
  background: #3b82f6;
}

/* 未登录时：登录/注册按钮 */
.btn-login-small { padding: 7px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; color: #2563eb; background: #fff; border: 1px solid #bfdbfe; text-decoration: none; transition: all 0.2s; }
.btn-login-small:hover { background: #eff6ff; }
.dark .btn-login-small { color: #60a5fa; background: #1f2937; border-color: #374151; }
.btn-register-small { padding: 7px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; color: #fff; background: #3b82f6; border: 1px solid #3b82f6; text-decoration: none; transition: all 0.2s; }
.btn-register-small:hover { background: #2563eb; }

/* ========== 用户头像 & 下拉菜单 ========== */
.user-area { position: relative; }
.user-avatar-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.35);
  transition: transform 0.2s;
  overflow: hidden;
  user-select: none;
}
.user-avatar-btn:hover { transform: scale(1.05); }
.dark .user-avatar-btn { border-color: #1f2937; }
.user-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

.user-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 240px; background: #fff; border: 1px solid #e5e7eb;
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.15);
  padding: 8px; z-index: 300;
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: all 0.2s ease;
}
.dark .user-dropdown { background: #1f2937; border-color: #374151; box-shadow: 0 12px 32px rgba(0,0,0,0.5); }
.user-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }

.user-dropdown .dropdown-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-bottom: 1px solid #f0f2f5; margin-bottom: 6px;
}
.dark .user-dropdown .dropdown-header { border-bottom-color: #374151; }
.user-dropdown .dropdown-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
}
.user-dropdown .dropdown-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-dropdown .dropdown-username { font-size: 14px; font-weight: 600; color: #1f2937; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dark .user-dropdown .dropdown-username { color: #e5e7eb; }
.user-dropdown .dropdown-email { font-size: 12px; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-dropdown .dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  font-size: 14px; color: #374151; text-decoration: none;
  cursor: pointer; transition: background 0.15s;
  border: none; background: transparent; width: 100%; text-align: left;
}
.dark .user-dropdown .dropdown-item { color: #d1d5db; }
.user-dropdown .dropdown-item:hover { background: #f3f4f6; color: #2563eb; }
.dark .user-dropdown .dropdown-item:hover { background: #374151; color: #60a5fa; }
.user-dropdown .dropdown-item.danger { color: #ef4444; }
.user-dropdown .dropdown-item.danger:hover { background: #fef2f2; color: #dc2626; }
.dark .user-dropdown .dropdown-item.danger:hover { background: #450a0a; }
.user-dropdown .divider { height: 1px; background: #f0f2f5; margin: 6px 0; }
.dark .user-dropdown .divider { background: #374151; }

/* ========== 移动端抽屉 ========== */
.mobile-drawer { position: fixed; top: 0; left: -280px; width: 280px; height: 100vh; background: #fff; box-shadow: 4px 0 24px rgba(0,0,0,0.15); z-index: 200; transition: left 0.3s ease; overflow-y: auto; padding: 20px 0; }
.dark .mobile-drawer { background: #1f2937; }
.mobile-drawer.open { left: 0; }
.mobile-drawer .drawer-header { padding: 0 20px 16px; border-bottom: 1px solid #f0f2f5; display: flex; justify-content: space-between; align-items: center; }
.dark .mobile-drawer .drawer-header { border-bottom-color: #374151; }
.mobile-drawer .drawer-close { font-size: 24px; color: #9ca3af; cursor: pointer; background: none; border: none; padding: 4px; }
.mobile-drawer .drawer-nav { padding: 12px; }
.mobile-drawer .drawer-item { border-bottom: 1px solid #f9fafb; }
.dark .mobile-drawer .drawer-item { border-bottom-color: #2d3748; }
.mobile-drawer .drawer-link { display: flex; justify-content: space-between; align-items: center; padding: 14px 12px; font-size: 15px; font-weight: 500; color: #374151; text-decoration: none; border-radius: 8px; transition: background 0.2s; }
.dark .mobile-drawer .drawer-link { color: #e5e7eb; }
.mobile-drawer .drawer-link:hover { background: #f3f4f6; }
.dark .mobile-drawer .drawer-link:hover { background: #374151; }
.mobile-drawer .drawer-sub { display: none; padding: 0 12px 8px 24px; }
.mobile-drawer .drawer-sub.open { display: block; }
.mobile-drawer .drawer-sub a { display: block; padding: 8px 12px; font-size: 14px; color: #6b7280; text-decoration: none; border-radius: 6px; }
.dark .mobile-drawer .drawer-sub a { color: #9ca3af; }
.mobile-drawer .drawer-sub a:hover { background: #f3f4f6; color: #2563eb; }
.dark .mobile-drawer .drawer-sub a:hover { background: #374151; color: #60a5fa; }
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 199; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; }
.drawer-overlay.show { opacity: 1; visibility: visible; }
.drawer-arrow { font-size: 12px; transition: transform 0.2s; }
.drawer-arrow.rotate { transform: rotate(180deg); }

/* 抽屉里的用户操作 */
.drawer-user-actions { padding: 12px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid #f0f2f5; }
.dark .drawer-user-actions { border-top-color: #374151; }
.drawer-user-actions a, .drawer-user-actions button { display: block; padding: 12px 14px; border-radius: 8px; font-size: 15px; text-align: center; text-decoration: none; transition: background 0.2s; border: none; cursor: pointer; }
.drawer-user-actions .btn-login { color: #2563eb; background: #eff6ff; }
.drawer-user-actions .btn-register { color: #fff; background: #3b82f6; }
.drawer-user-actions .btn-logout { color: #ef4444; background: #fef2f2; }

/* ========== 移动端头部布局 ========== */
.mobile-header { display: grid; grid-template-columns: 44px 1fr 44px 44px; align-items: center; gap: 4px; }
.mobile-header .logo { text-align: center; }
.mobile-header .logo img { width: 120px; height: auto; display: inline-block; }
.mobile-header .icon-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: #f3f4f6; border: none; font-size: 18px; cursor: pointer; color: #374151; transition: background 0.2s; }
.dark .mobile-header .icon-btn { background: #374151; color: #e5e7eb; }

/* ========== 移动端搜索条 ========== */
.mobile-search-bar { display: none; position: fixed; top: 0; left: 0; right: 0; background: #fff; padding: 12px 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.1); z-index: 210; align-items: center; gap: 10px; }
.dark .mobile-search-bar { background: #1f2937; }
.mobile-search-bar.show { display: flex; }
.mobile-search-bar input { flex: 1; height: 40px; padding: 0 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px; outline: none; background: #f9fafb; }
.dark .mobile-search-bar input { background: #374151; border-color: #4b5563; color: #fff; }
.mobile-search-bar .close-search { background: none; border: none; font-size: 20px; color: #9ca3af; cursor: pointer; padding: 4px 8px; }
/* ========== 友情链接 ========== */
.friendlinks-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px 24px;
  margin-top: 24px;
}
.dark .friendlinks-wrap {
  background: #1f2937;
  border-color: #374151;
}
.friendlinks-title {
  font-size: 15px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 4px solid #3b82f6;
}
.dark .friendlinks-title {
  color: #e5e7eb;
}
.friendlinks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
}
.friendlinks-list a {
  font-size: 14px;
  color: #6b7280;
  text-decoration: none;
  transition: color 0.2s;
}
.friendlinks-list a:hover {
  color: #2563eb;
  text-decoration: underline;
}
.dark .friendlinks-list a {
  color: #9ca3af;
}
.dark .friendlinks-list a:hover {
  color: #60a5fa;
}
/* ========== 公共底部 ========== */
.site-footer {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  margin-top: 40px;
  padding: 36px 0 20px;
}
.dark .site-footer {
  background: #111827;
  border-top-color: #1f2937;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1.2fr;
  gap: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid #f0f2f5;
}
.dark .footer-grid {
  border-bottom-color: #1f2937;
}
.footer-col {
  min-width: 0;
}
.footer-title {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 12px 0;
  padding-left: 8px;
  border-left: 3px solid #3b82f6;
}
.dark .footer-title {
  color: #e5e7eb;
}
.footer-desc {
  font-size: 13px;
  line-height: 1.7;
  color: #6b7280;
  margin: 0;
}
.dark .footer-desc {
  color: #9ca3af;
}
.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-links li {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
  line-height: 1.6;
}
.dark .footer-links li {
  color: #9ca3af;
}
.footer-links a {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover {
  color: #2563eb;
}
.dark .footer-links a {
  color: #9ca3af;
}
.dark .footer-links a:hover {
  color: #60a5fa;
}
.footer-bottom {
  padding-top: 18px;
  text-align: center;
  font-size: 13px;
  color: #9ca3af;
  line-height: 1.8;
}
.footer-bottom a {
  color: #9ca3af;
  text-decoration: none;
}
.footer-bottom a:hover {
  color: #3b82f6;
}


@media (max-width: 768px) {
  .desktop-nav, .desktop-search, .desktop-dark, .desktop-user-actions, .btn-history { display: none !important; }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .site-footer {
    padding: 24px 0 16px;
  }
  .footer-bottom {
    font-size: 12px;
  }
}
@media (min-width: 769px) {
  .mobile-header { display: none !important; }
  .mobile-drawer, .drawer-overlay, .mobile-search-bar { display: none !important; }
}