/* Shared theme layer for every static page. */
:root[data-theme="light"] {
  --bg: #f5f7fa; --bg-elev: #ffffff; --surface: #ffffff; --surface-hover: #f0f4f8;
  --surface-muted: #f8fafc; --glass: rgba(255,255,255,.9); --header-bg: rgba(255,255,255,.88);
  --line: rgba(29,33,41,.12); --line-soft: rgba(29,33,41,.08); --line-strong: rgba(22,93,255,.32);
  --text: #1d2129; --text-soft: #4e5969; --muted: #86909c; --brand: #165dff; --brand-soft: #4080ff;
  --brand-deep: #0e42c8; --brand-strong: #165dff; --accent: #36cfc9; --glow: rgba(22,93,255,.25); --glow-soft: rgba(22,93,255,.1);
  --danger: #e5484d; --warn: #f59e0b; --ok: #16a34a; --success: #16a34a;
}
:root[data-theme="light"] body { background: var(--bg); color: var(--text); }
:root[data-theme="light"] body::before { background: radial-gradient(60% 55% at 12% 8%, rgba(22,93,255,.08), transparent 55%), radial-gradient(55% 50% at 88% 0%, rgba(54,207,201,.08), transparent 50%); }
:root[data-theme="light"] body::after { background-image: linear-gradient(rgba(29,33,41,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(29,33,41,.025) 1px, transparent 1px); }
.theme-toggle-shared { position: fixed; top: 14px; right: 18px; z-index: 1000; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text-soft); cursor: pointer; font-size: 18px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.theme-toggle-shared:hover { color: var(--text); border-color: var(--line-strong); transform: translateY(-2px); }
.header .theme-toggle-shared { position: static; box-shadow: none; }
.language-picker-shared { position: fixed; top: 14px; right: 66px; z-index: 1000; }
.header .language-picker-shared { position: relative; top: auto; right: auto; }
.language-toggle-shared { height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text-soft); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.header .language-toggle-shared { box-shadow: none; }
.language-menu-shared { position: absolute; top: calc(100% + 8px); right: 0; min-width: 156px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev, var(--surface)); box-shadow: 0 18px 40px rgba(0,0,0,.18); display: none; }
.language-picker-shared.open .language-menu-shared { display: block; }
.language-option-shared { width: 100%; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text-soft); display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; text-align: left; }
.language-option-shared:hover, .language-option-shared.active { background: var(--surface-hover); color: var(--text); }
.language-option-shared .flag { font-size: 18px; }
@media (max-width: 640px) { .theme-toggle-shared { top: 12px; right: 12px; } }

/* ===== 共享顶栏：中间导航 + 右侧图标按钮（控制台风格，全走主题变量） ===== */
.header-nav { display: flex; align-items: center; gap: 4px; }
.header-nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--text-soft); text-decoration: none;
  font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.header-nav a svg { width: 15px; height: 15px; flex: 0 0 auto; }
.header-nav a:hover { color: var(--text); background: var(--surface-hover); }
.header-nav a.active { color: var(--brand); background: var(--glow-soft); font-weight: 600; }
.header .icon-btn {
  position: relative; width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-soft); cursor: pointer; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  transition: background .15s, color .15s;
}
.header .icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.header .icon-btn svg { width: 18px; height: 18px; }
.header-badge {
  position: absolute; top: 1px; right: -1px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: #e5484d; color: #fff; font-size: 10px; font-weight: 700;
  line-height: 16px; text-align: center; pointer-events: none;
}
/* 未读消息角标：默认隐藏，有未读时加 .show */
.message-badge { display: none; }
.message-badge.show { display: block; }
/* 顶栏登录按钮（各页面 .btn 样式不一，顶栏统一用此类） */
.header-auth-btn {
  min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text-soft); font-size: 14px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.header-auth-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--line-strong); }

/* 顶栏悬浮提示：data-tip 属性即时提示，替代原生 title 的延迟 */
.header [data-tip] { position: relative; }
.header [data-tip]::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  padding: 4px 10px; border-radius: 6px;
  background: var(--text); color: var(--bg);
  font-size: 12px; font-weight: 500; line-height: 1.4; white-space: nowrap;
  /* 用 display 而非仅 opacity 隐藏：隐藏态不参与布局，避免撑出页面横向滚动 */
  display: none; pointer-events: none;
  z-index: 300;
}
.header [data-tip]:hover::after,
.header [data-tip]:focus-visible::after { display: block; animation: tip-fade-in .15s ease; }
@keyframes tip-fade-in { from { opacity: 0; } to { opacity: 1; } }
.avatar-btn {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand-soft), var(--brand)); color: var(--bg);
  font-size: 14px; font-weight: 700; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
/* 顶栏内的主题切换 / 语言切换对齐图标按钮尺寸 */
.header .logo span { white-space: nowrap; }
.header .theme-toggle-shared {
  position: static; width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; box-shadow: none; font-size: 16px;
}
.header .theme-toggle-shared:hover { background: var(--surface-hover); transform: none; }
.header .language-picker-shared { position: relative; top: auto; right: auto; }
.header .language-toggle-shared {
  height: 36px; border: 0; border-radius: 8px; background: transparent; box-shadow: none;
  white-space: nowrap;
}
.header .language-toggle-shared:hover { background: var(--surface-hover); }
@media (max-width: 480px) {
  /* 窄屏语言切换只留旗帜图标，避免顶栏拥挤 */
  .header .language-toggle-shared { padding: 0 8px; }
  .header .language-toggle-shared .current-name { display: none; }
}
/* 移动端：中间导航收起为汉堡面板 */
.header-menu-toggle {
  display: none; width: 36px; height: 36px; border: 0; border-radius: 8px; flex: 0 0 auto;
  background: transparent; color: var(--text-soft); cursor: pointer;
  align-items: center; justify-content: center; margin-right: auto;
}
.header-menu-toggle svg { width: 20px; height: 20px; }
.header-menu-toggle:hover { background: var(--surface-hover); color: var(--text); }
@media (max-width: 768px) {
  .header-menu-toggle { display: inline-flex; }
  .header-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 99;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 8px 12px 12px;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .header.nav-open .header-nav { display: flex; }
  .header-nav a { padding: 10px 12px; }
}
@media (max-width: 480px) {
  /* 超窄屏压缩图标尺寸，保证顶栏单行放下 */
  .header .header-right { gap: 6px; }
  .header .icon-btn { width: 32px; height: 32px; }
  .header .theme-toggle-shared { width: 32px; height: 32px; }
  .header-menu-toggle { width: 32px; height: 32px; }
}
