/* ============================================================
   基础重置
   ============================================================ */
* { 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;
  transition: all 0.15s;
}
.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-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;
  padding-bottom: 16px;
  margin-bottom: -16px;
}

/* 头像按钮 */
.user-avatar-btn {
  position: relative;
  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: visible;          /* ★ 允许红点溢出 */
  user-select: none;
}
.user-avatar-btn:hover { transform: scale(1.05); }
.user-avatar-btn a {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;           /* ★ 图片单独裁剪 */
  color: inherit;
  text-decoration: none;
}
.user-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dark .user-avatar-btn { border-color: #1f2937; }

/* 下拉菜单 */
.user-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  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;
  pointer-events: none;
}
.dark .user-dropdown {
  background: #1f2937;
  border-color: #374151;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.user-area:hover .user-dropdown,
.user-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* 下拉顶部的用户信息块 */
.user-dropdown .dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #f0f2f5;
  margin-bottom: 6px;
  border-radius: 8px;
  transition: background 0.15s;
}
.user-dropdown .dropdown-header:hover { background: #f3f4f6; }
.dark .user-dropdown .dropdown-header { border-bottom-color: #374151; }
.dark .user-dropdown .dropdown-header:hover { background: #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;
}

/* 下拉项（已合并 position:relative） */
.user-dropdown .dropdown-item {
  position: relative;
  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; }

/* ============================================================
   消息红点（头像 / 下拉 / 手机端）
   ============================================================ */
.msg-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  z-index: 2;
  pointer-events: none;
  animation: badgePop 0.3s ease;
}
.msg-badge.big { padding: 0 6px; }

@keyframes badgePop {
  0%   { transform: scale(0.5); }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.msg-badge-inline {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
}

.msg-badge-mobile {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

/* ============================================================
   移动端抽屉
   ============================================================ */
.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; }

/* ============================================================
   移动端头部（图标 + logo + 消息 + 搜索 + 主题）
   ============================================================ */
.mobile-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px 44px 44px;   /* ★ 5 列 */
  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;
  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; }

/* ============================================================
   响应式
   ============================================================ */

/* PC 端（>= 769px）：隐藏手机端元素 */
@media (min-width: 769px) {
  .mobile-header { display: none !important; }
  .mobile-drawer,
  .drawer-overlay,
  .mobile-search-bar { display: none !important; }
}

/* 手机端（<= 768px）：隐藏 PC 端元素，底部单列 */
@media (max-width: 768px) {
  .desktop-nav,
  .desktop-search,
  .desktop-dark,
  .desktop-user-actions,
  .btn-history { display: none !important; }

  /* ★ footer-grid：手机端隐藏四列，只显示底部版权 */
  .footer-grid { display: none; }

  .site-footer { padding: 24px 0 16px; }
  .footer-bottom { font-size: 12px; padding-top: 0; }
}