/* ============================================================
   统一顶栏组件（纸感主题）
   
   用法：页面里放
     <header class="topbar">
       <a class="brand" href="/index.html"><span class="brand-dot"></span>yc6n</a>
       <nav class="topbar-nav">…</nav>
       <div class="topbar-actions"><!-- user-nav 会往这里注入 --></div>
     </header>
   
   注意：user-nav.js 需要 .nav-links 容器才能注入登录态。
   这里让 .topbar-actions 同时带 .nav-links 类，避免改 JS。
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 60px;
  padding: 0 max(24px, calc((100vw - var(--track)) / 2));
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

/* 品牌字标
   中英视觉对齐：汉字墨迹 ≈ 0.822em，拉丁小写 x-height ≈ 0.526em。
   yc6n 全小写，同字号下视觉高度只有旁边中文的约 64%，
   因此用 19px + 800 字重补偿到 ≈0.85 的墨迹比（实测等重）。 */
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  line-height: 1;
  height: 22px;
  font-weight: 800;
  font-size: 19px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.02em;
  flex: 0 0 auto;
}
.brand:hover { color: var(--accent); text-decoration: none; }

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  flex: 0 0 9px;
  position: relative;
  top: -0.5px;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: 8px;
  line-height: 1;
}
.topbar-nav a {
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
}
.topbar-nav a:hover { color: var(--accent); }
.topbar-nav a.is-active { color: var(--accent); }

/* 动作区：同时承载 user-nav 注入的登录态 */
.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* user-nav 注入后的横向排列 */
.topbar-actions .nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  min-width: 0;
}

/* 未登录时的「登录」入口：与导航同形，不做成蓝色下划线链接 */
.nav-login {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: all .16s;
  white-space: nowrap;
}
.nav-login:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* 已登录时的用户名链接 */
.topbar-actions .nav-user-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  min-width: 0;
}
.topbar-actions .nav-user-link:hover {
  color: var(--accent);
  text-decoration: none;
}
.topbar-actions .nav-user-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

/* 管理后台入口 */
.topbar-actions .nav-admin-link {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-actions .nav-admin-link:hover {
  color: var(--accent);
  text-decoration: none;
}

/* 退出按钮 */
.topbar-actions .nav-logout {
  border: none;
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.topbar-actions .nav-logout:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* 移动端：隐藏中间导航，保留品牌与动作区 */
@media (max-width: 720px) {
  .topbar {
    height: 56px;
    padding: 0 16px;
    gap: 10px;
  }
  .topbar-nav { display: none; }
  .brand { font-size: 18px; }
}
