/* ============================================================
   顶栏 v2 · 通栏白条（20261203）
   ------------------------------------------------------------
   只重绘外观：品牌区 / 导航 / 主题·搜索 / 控制台·免费下载
   交互一律沿用原逻辑（下拉面板 popover、站内搜索、主题切换、
   汉堡菜单 .mnav），不改任何 JS、不改任何 href。

   加载顺序：site.css → premium.css → theme.css → topbar.css
   ============================================================ */

/* ---------------- 1. 外壳：整条通栏 ---------------- */

.topbar{
  padding:12px 18px 0;
  padding-top:calc(12px + env(safe-area-inset-top,0px));
}
.topbar,.topbar.scrolled{box-shadow:none}

.topbar .wrap{
  width:100%;
  max-width:1720px;
  height:66px;
  padding:0 14px 0 16px;
  gap:0;
  justify-content:flex-start;
  border-radius:20px;
  background:var(--bg);
  border:1px solid color-mix(in srgb,var(--fg) 9%,transparent);
  box-shadow:0 1px 2px rgba(17,24,39,.04), 0 16px 40px -26px rgba(17,24,39,.42);
  -webkit-backdrop-filter:none;
  backdrop-filter:none;
}
/* 滚动后不再收窄，只把阴影压深一点，整条保持同一高度 */
.topbar.scrolled .wrap{
  height:66px;
  background:var(--bg);
  box-shadow:0 1px 2px rgba(17,24,39,.05), 0 20px 46px -26px rgba(17,24,39,.5);
}

/* ---------------- 2. 品牌 ---------------- */

.topbar .brand{
  margin-right:0;
  gap:10px;
  font-size:19px;
  font-weight:700;
  letter-spacing:-.025em;
  color:var(--fg-strong);
}
.topbar .brand i{
  width:36px;height:36px;
  border-radius:11px;
}

/* ---------------- 3. 导航 ---------------- */

.topbar .nav{
  margin-left:20px;
  gap:2px;
}
.topbar .nav-btn{
  height:40px;
  padding:0 13px;
  border-radius:10px;
  font-size:15px;
  font-weight:500;
  color:var(--fg);
}
.topbar .nav-btn:hover{background:var(--bg-mute);color:var(--fg)}
.topbar .nav-item.open .nav-btn{background:var(--bg-mute);color:var(--fg)}
.topbar .nav-btn svg{
  width:10px;height:6px;
  opacity:.45;
}
/* 旧版 hover 下划线在新圆角块里多余，关掉 */
.topbar .nav-btn::before{content:none}

/* ---------------- 4. 右侧动作区 ---------------- */

.topbar .acts{
  margin-left:auto;
  gap:8px;
  padding-left:18px;
}
.topbar .tbtn,.topbar .sbtn{
  width:36px;height:36px;
  border-radius:10px;
  color:var(--fg-muted);
}
.topbar .tbtn svg,.topbar .sbtn svg{width:18px;height:18px}
.topbar .tbtn:hover,.topbar .sbtn:hover{background:var(--bg-mute);color:var(--fg)}

.topbar .acts .btn{
  height:40px;
  padding:0 22px;
  border-radius:11px;
  font-size:15px;
  font-weight:600;
  gap:0;
}
.topbar .acts .btn.ghost{
  background:var(--bg-mute);
  border-color:transparent;
  color:var(--fg);
}
.topbar .acts .btn.ghost:hover{
  background:color-mix(in srgb,var(--fg) 13%,var(--bg-mute));
  border-color:transparent;
  color:var(--fg);
}
.topbar .acts .btn.primary{
  background:var(--black);
  border-color:transparent;
  color:var(--bg);
}
.topbar .acts .btn.primary::after{content:none}
.topbar .acts .btn.primary:hover{
  background:var(--black);
  transform:none;
  box-shadow:0 8px 20px -12px rgba(0,0,0,.7);
}

/* 汉堡按钮与动作区基线对齐 */
.topbar .burger{width:36px;height:36px;border-radius:10px}

/* ---------------- 5. 下拉面板与外壳对齐 ---------------- */

.topbar .panel{top:88px}
.topbar .panel:popover-open{top:88px}
.topbar .panel{max-height:calc(100vh - 116px)}

/* ---------------- 6. 深色：靠变量自动翻转，只补阴影与描边 ---------------- */

html[data-theme="dark"] .topbar .wrap{
  box-shadow:0 1px 2px rgba(0,0,0,.5), 0 20px 46px -26px rgba(0,0,0,.95);
}
/* 深色下灰底按钮要跟条子拉开一档，否则看不出来是个按钮 */
html[data-theme="dark"] .topbar .acts .btn.ghost{background:#242424}
@media (prefers-color-scheme:dark){
  html:not([data-theme="light"]) .topbar .wrap{
    box-shadow:0 1px 2px rgba(0,0,0,.5), 0 20px 46px -26px rgba(0,0,0,.95);
  }
  html:not([data-theme="light"]) .topbar .acts .btn.ghost{background:#242424}
}

/* ---------------- 7. 中等宽度：收紧一格，保证 1141px 也摆得下 ---------------- */

@media (min-width:1141px) and (max-width:1400px){
  .topbar .brand{font-size:17px;gap:9px}
  .topbar .brand i{width:32px;height:32px;border-radius:10px}
  .topbar .nav{margin-left:12px;gap:0}
  .topbar .nav-btn{height:36px;padding:0 9px;font-size:13.5px}
  .topbar .acts{gap:6px;padding-left:12px}
  .topbar .acts .btn{height:36px;padding:0 15px;font-size:13.5px}
  .topbar .tbtn,.topbar .sbtn{width:34px;height:34px}
  .topbar .tbtn svg,.topbar .sbtn svg{width:17px;height:17px}
  .topbar .burger{width:34px;height:34px}
}

/* ---------------- 8. 平板/手机：菜单收进汉堡，条子缩短 ---------------- */

@media (max-width:1140px){
  .topbar{padding:10px 12px 0;padding-top:calc(10px + env(safe-area-inset-top,0px))}
  .topbar .wrap{
    height:60px;
    padding:0 8px 0 12px;
    border-radius:16px;
  }
  .topbar .brand{font-size:16.5px;gap:8px}
  .topbar .brand i{width:30px;height:30px;border-radius:9px}
  .topbar .acts{gap:6px;padding-left:0}
  .topbar .tbtn,.topbar .sbtn{width:36px;height:36px}
  .topbar .acts .btn{height:36px;padding:0 14px;font-size:13.5px}
  .mnav{top:calc(80px + env(safe-area-inset-top,0px))}
}

@media (max-width:640px){
  .topbar .wrap{height:56px;border-radius:14px}
  .topbar .brand{font-size:15px;gap:7px}
  .topbar .brand i{width:26px;height:26px;border-radius:8px}
  .topbar .acts{gap:4px}
  .topbar .tbtn,.topbar .sbtn{width:32px;height:32px}
  .topbar .tbtn svg,.topbar .sbtn svg{width:15px;height:15px}
  .topbar .acts .btn{height:32px;padding:0 12px;font-size:13px}
  .topbar .burger{width:32px;height:32px}
  .mnav{top:calc(72px + env(safe-area-inset-top,0px))}
}

/* 站内搜索入口在手机菜单里已有，窄屏让位给主题开关（沿用原策略） */
@media (max-width:560px){
  .topbar .acts .sbtn{display:none}
  .topbar .acts .btn.primary{padding:0 12px;font-size:12.5px}
}
@media (max-width:400px){
  .topbar .acts .btn.primary{display:none}
}
