/* ============================================================
   tool-topbar.css — 独立工具页「统一顶栏」规范（全工具页面统一）
   ============================================================
   规范（新增独立工具页时必须遵守，禁止自造顶栏）：

   1. 样式引入顺序固定：style.css → theme.css → tool-topbar.css，
      并给 <body> 加 class="tool-page"。
   2. 顶栏结构必须与工作流画布 / 写作工作台完全一致（顶栏本体为透明浮动，
      不带整条毛玻璃底板，玻璃质感只出现在各信息丸/动作丸/星点胶囊上）：
      header.top-brand-bar
        ├ .topbar-left
        │   └ .canvas-topbar-pill
        │       ├ a.canvas-topbar-back        （返回工具台，href="/"）
        │       ├ span.canvas-topbar-divider
        │       ├ span.canvas-topbar-title    （工具名，如「元星电商套图工作台」）
        │       └ [可选] button.canvas-topbar-name（上下文切换，有会话概念的页才加）
        └ .topbar-right
            ├ .topbar-right-zone
            │   ├ button.topbar-icon-btn  操作引导（fa-graduation-cap）
            │   ├ button.topbar-icon-btn  BUG反馈（fa-bug）
            │   └ button.topbar-icon-btn  公告（fa-bell + span.topbar-btn-dot）
            ├ .platform-coin-display#writing-stars   （星点，AccountMenu 自动填充）
            ├ button.topbar-user-btn#<页前缀>-user-btn
            └ .topbar-user-menu#<页前缀>-user-menu
   3. 行为由 modules/AccountMenu.js（账户/星点/流水）+ 各页 *-boot.js 驱动；
      操作引导 / BUG反馈 / 公告走 /api/guides / /api/bug-report / /api/announcements，
      弹窗使用下方 .tool-toolbar-* 通用样式。
   ============================================================ */

body.tool-page {
  padding-top: 64px; /* .top-brand-bar 高度（theme.css --topbar-h） */
  background: var(--ui-bg);
  /* 工具页是普通文档流页面：解除 style.css 画布 body 的
     height:100dvh / display:flex / overflow:hidden，恢复整页滚动，
     否则顶栏下方内容会被裁掉 */
  height: auto !important;
  min-height: 100vh !important;
  display: block !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

/* 顶栏本体：无玻璃底板（与画布皮肤一致），只留浮动的信息丸/动作丸，
   玻璃质感由各 pill 自带，压掉 theme.css 的整条毛玻璃 */
body.tool-page .top-brand-bar {
  height:64px !important; min-height:64px !important; padding:0 16px !important; pointer-events:none;
  background: transparent !important;
  -webkit-backdrop-filter: var(--ui-blur) !important;
  backdrop-filter: var(--ui-blur) !important;
  box-shadow: none !important;
  border-bottom: 0 !important;
}

/* ---- 左侧信息丸：返回 + 工具名（与画布 / 写作页同款） ---- */
body.tool-page .canvas-topbar-pill {
  pointer-events:auto; min-width:0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 10px 0 5px;
  border-radius: 12px;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  box-shadow: none;
  -webkit-backdrop-filter: var(--ui-blur) ;
  backdrop-filter: var(--ui-blur) ;
}
body.tool-page .canvas-topbar-back {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--ui-muted);
  text-decoration: none;
  font-size: 13px;
  transition: background 0.16s ease, color 0.16s ease;
}
body.tool-page .canvas-topbar-back:hover {
  background: rgba(var(--ui-ink-rgb), 0.08);
  color: var(--ui-text);
}
body.tool-page .canvas-topbar-divider {
  width: 1px;
  height: 18px;
  flex: 0 0 auto;
  background: rgba(var(--ui-ink-rgb), 0.12);
}
body.tool-page .canvas-topbar-title {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--ui-text);
  white-space: nowrap;
}
body.tool-page .canvas-topbar-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 220px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ui-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
body.tool-page .canvas-topbar-name:hover {
  background: rgba(var(--ui-ink-rgb), 0.07);
  color: var(--ui-text);
}
body.tool-page .canvas-topbar-name i {
  font-size: 10px;
  opacity: 0.7;
  flex: 0 0 auto;
}

/* ---- 右侧动作区：恢复文档流位置（覆盖 theme.css 的画布绝对定位），
        并套用与画布 / 写作页一致的深色信息丸 ---- */
body.tool-page .topbar-right {
  pointer-events:auto;
  position: static !important;
  height: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
body.tool-page .topbar-right-zone {
  box-sizing:border-box; height:44px !important;
  position: static !important;
  top: auto !important;
  right: auto !important;
  transform: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 3px !important;
  border-radius: 12px !important;
  background: var(--ui-panel) !important;
  border: 1px solid var(--ui-border) !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: var(--ui-blur) !important;
  backdrop-filter: var(--ui-blur) !important;
}
body.tool-page .topbar-right-zone .topbar-icon-btn {
  position: relative !important;
  width: auto !important;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 10px !important;
  gap: 7px !important;
  border: 0 !important;
  border-radius: 9px !important;
  background: transparent !important;
  color: var(--ui-muted) !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  display: inline-flex !important;
  align-items: center !important;
  white-space: nowrap !important;
  cursor: pointer !important;
}
body.tool-page .topbar-right-zone .topbar-icon-btn:hover {
  background: rgba(var(--ui-ink-rgb), 0.07) !important;
  color: var(--ui-text) !important;
}
body.tool-page .topbar-right-zone .topbar-btn-label { line-height: 1 !important; }
body.tool-page .topbar-btn-dot {
  position: absolute !important;
  top: 3px !important;
  right: 4px !important;
  width: 7px !important;
  height: 7px !important;
  border-radius: 50% !important;
  background: var(--ui-danger-fill) !important;
  box-shadow: 0 0 0 2px rgba(var(--ui-shadow-rgb), var(--ui-shadow-alpha)) !important;
}

/* ---- 星点：独立小胶囊（点击直达星点流水，由 AccountMenu 绑定） ---- */
body.tool-page .topbar-right > .platform-coin-display {
  gap: 6px !important;
  padding: 0 12px !important;
  height: 44px !important;
  min-height: 44px !important;
  border-radius: 10px !important;
  background: var(--ui-panel) !important;
  border: 1px solid var(--ui-border) !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: var(--ui-blur) !important;
  backdrop-filter: var(--ui-blur) !important;
  font-size: 12.5px !important;
}
body.tool-page .topbar-right > .platform-coin-display[hidden] { display: none !important; }
body.tool-page .topbar-right > .platform-coin-display .platform-coin-amount {
  font-size: 12.5px !important;
  font-weight: 600 !important;
  color: var(--ui-text) !important;
}

/* ---- 头像：独立圆形（AccountMenu 填充首字母 + 完整账户面板） ---- */
body.tool-page .topbar-right > .topbar-user-btn {
  width: 44px !important;
  height: 44px !important;
  font-size: 13px !important;
  flex: 0 0 auto !important;
}
body.tool-page .topbar-user-menu { top: calc(100% + 8px) !important; }
body.tool-page .topbar-user-menu-item { cursor: pointer !important; border-radius: 8px !important; }
body.tool-page .topbar-user-menu-item:hover { background: rgba(var(--ui-ink-rgb), 0.08) !important; color: var(--ui-text) !important; }

/* ---- 窄屏：隐藏按钮文字只留图标 ---- */
@media (max-width: 1080px) {
  body.tool-page .topbar-right-zone .topbar-btn-label { display: none !important; }
  body.tool-page .topbar-right-zone .topbar-icon-btn {
    width: 36px !important;
    padding: 0 !important;
    justify-content: center !important;
  }
}

/* ---- 顶栏工具按钮共用弹窗（操作引导 / BUG反馈 / 公告） ---- */
body.tool-page .tool-toolbar-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--ui-shadow-rgb), 0.6);
}
body.tool-page .tool-toolbar-modal[hidden] { display: none !important; }
body.tool-page .tool-toolbar-modal-card {
  width: min(560px, 92vw);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: var(--ui-panel);
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(var(--ui-shadow-rgb), var(--ui-shadow-alpha));
  overflow: hidden;
}
body.tool-page .tool-toolbar-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ui-border);
  font-size: 14px;
  font-weight: 600;
  color: var(--ui-text);
}
body.tool-page .tool-toolbar-modal-x {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--ui-border);
  background: transparent;
  color: var(--ui-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
body.tool-page .tool-toolbar-modal-x:hover {
  color: var(--ui-text);
  background: rgba(var(--ui-ink-rgb), 0.06);
}
body.tool-page .tool-toolbar-modal-body {
  padding: 16px 18px;
  overflow: auto;
  color: var(--ui-text);
  font-size: 13px;
  line-height: 1.7;
}
:is(body.tool-page, body.is-writing-workspace-active) .tool-toolbar-tips p { margin: 0 0 10px; }
:is(body.tool-page, body.is-writing-workspace-active) .tool-toolbar-tips b { color: var(--ui-text); }
.tool-guide-item { padding:12px 0; border-bottom:1px solid var(--ui-border); }
.tool-guide-item:last-child { border-bottom:0; }
.tool-guide-caption { white-space:pre-wrap; overflow-wrap:anywhere; }
.tool-content-image { display:block; margin:12px 0; }
.tool-content-image img { display:block; max-width:100%; height:auto; border-radius:8px; }
body.tool-page .tool-toolbar-form label {
  display: block;
  margin-bottom: 12px;
  color: var(--ui-text);
  font-size: 12.5px;
}
body.tool-page .tool-toolbar-form textarea,
body.tool-page .tool-toolbar-form input {
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--ui-border);
  background: rgba(var(--ui-ink-rgb), 0.04);
  color: var(--ui-text);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  box-sizing: border-box;
}
body.tool-page .tool-toolbar-form textarea:focus,
body.tool-page .tool-toolbar-form input:focus {
  outline: none;
  border-color: var(--ui-border-strong);
}
body.tool-page .tool-toolbar-actions { display: flex; justify-content: flex-end; }
body.tool-page .tool-toolbar-primary {
  height: 34px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--ui-action);
  color: var(--ui-on-accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
body.tool-page .tool-toolbar-primary:hover { filter: brightness(1.08); }
body.tool-page .tool-toolbar-msg { min-height: 18px; margin: 4px 0 10px; font-size: 12.5px; color: var(--ui-muted); }
body.tool-page .tool-toolbar-msg.is-err { color:var(--ui-danger); }
body.tool-page .tool-toolbar-msg.is-ok { color: var(--ui-text); }
:is(body.tool-page, body.is-writing-workspace-active) .tool-toolbar-empty { text-align: center; color: var(--ui-muted); padding: 18px 0; }
:is(body.tool-page, body.is-writing-workspace-active) .tool-ann-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--ui-border);
}
:is(body.tool-page, body.is-writing-workspace-active) .tool-ann-item:last-child { border-bottom: 0; }
:is(body.tool-page, body.is-writing-workspace-active) .tool-ann-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
:is(body.tool-page, body.is-writing-workspace-active) .tool-ann-title { color: var(--ui-text); font-weight: 600; font-size: 13.5px; }
:is(body.tool-page, body.is-writing-workspace-active) .tool-ann-time { color: var(--ui-muted); font-size: 11.5px; white-space: nowrap; }
:is(body.tool-page, body.is-writing-workspace-active) .tool-ann-body { color: var(--ui-text); white-space: pre-wrap; word-break: break-word; }

.tool-theme-wrap {position:relative;display:flex;align-items:center;pointer-events:auto;}
.tool-theme-wrap .topbar-icon-btn {position:relative;display:inline-flex;align-items:center;justify-content:center;width:36px !important;height:36px !important;min-height:36px !important;padding:0 !important;border:0;border-radius:8px;background:transparent;color:var(--ui-muted);cursor:pointer;}
.tool-theme-wrap .topbar-icon-btn:hover {background:var(--ui-hover);color:var(--ui-text);}
.tool-theme-wrap [hidden] {display:none !important;}
.tool-theme-status {position:fixed;top:66px;right:16px;max-width:calc(100vw - 32px);padding:10px 14px;border:1px solid var(--ui-border);border-radius:9px;background:var(--ui-panel);color:var(--ui-danger);font-size:12px;box-shadow:var(--ui-shadow);}
.tool-theme-status:empty {display:none;}
@media(max-width:760px) {
  body.tool-page .top-brand-bar {padding:0 8px !important;gap:8px;}
  body.tool-page .topbar-left {min-width:0;flex:1;}
  body.tool-page .canvas-topbar-title {font-size:12px;overflow:hidden;text-overflow:ellipsis;}
  body.tool-page .canvas-topbar-name, body.tool-page .canvas-topbar-divider {display:none;}
  body.tool-page .canvas-topbar-pill {gap:5px;max-width:100%;padding-right:8px;}
  body.tool-page .topbar-right {gap:6px;}
  body.tool-page .topbar-right-zone {gap:0 !important;}
  body.tool-page .topbar-right > .platform-coin-display {padding:0 8px !important;}
  body.tool-page .topbar-right-zone .topbar-icon-btn {width:28px !important;}
  .tool-theme-wrap .topbar-icon-btn {width:28px !important;}
}
