/* ==================================================================
   mindmap5.3 · css/unified-toolbar.css —— 单行共用顶栏与专注布局
   颜色、边框、圆角和状态只消费 trial-05 的 --ui-* 令牌。
   ================================================================== */
body.toolbar-ready { --menubar-h: var(--ui-topbar-h); }
body.toolbar-ready.toolbar-floating { --menubar-h: 0px; }
body.toolbar-ready #menubar {
  height: var(--ui-topbar-h); min-height: var(--ui-topbar-h); max-height: var(--ui-topbar-h);
  gap: var(--ui-toolbar-gap); padding: 0 var(--ui-topbar-padding); overflow: visible;
  flex-flow: row nowrap; justify-content: flex-start; box-sizing: border-box;
}
body.toolbar-ready #menubar[aria-hidden="true"] { visibility: hidden; pointer-events: none; }
/* 更多菜单属于顶栏层，管理器打开时连同弹层一起置于资料列表之上。 */
body.toolbar-ready.reading-manager-open #menubar { z-index: calc(var(--z-manager) + 1); }
body.toolbar-ready #menubar .topbar-zone-a { flex: none; width: auto; }
body.toolbar-ready #menubar .topbar-zone-b { flex: none; width: var(--ui-topbar-book-w); padding-left: var(--ui-control-gap); }
body.toolbar-ready #menubar .topbar-zone-c { flex: none; margin-left: 0; padding-left: var(--ui-control-gap); }
body.toolbar-ready .topbar-zone[hidden] { display: none !important; }
#menubar .shell-view[hidden] { display: none !important; }
body.toolbar-ready #rm-manager-close .rm-close-label { display: inline; }
body.toolbar-ready #rm-manager-close > [aria-hidden] { display: inline-flex; }
body.toolbar-ready .reader-topbar-direct { gap: var(--ui-toolbar-gap); }
body.toolbar-ready .reader-topbar-button {
  height: var(--ui-icon-button-size); min-height: var(--ui-icon-button-size); min-width: var(--ui-icon-button-size);
  box-sizing: border-box; font-size: 12px; line-height: var(--ui-button-line-height); padding: 5px 6px;
}
body.toolbar-ready .reader-topbar-button[hidden],body.toolbar-ready .toolbar-global-overflow[hidden] { display: none !important; }
body.toolbar-ready #menubar .mb-logo { width: 30px; height: 30px; }
body.toolbar-ready .shell-modes { box-sizing: border-box; height: var(--ui-icon-button-size); }
body.toolbar-ready #menubar .shell-modes .shell-view { min-height: 28px; height: 28px; }
body.toolbar-ready [data-topbar-action="documents"] { justify-content: flex-start; width: 100%; min-width: 0; }
body.toolbar-ready [data-topbar-action="documents"] .reader-topbar-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
body.toolbar-ready [data-topbar-action="documents"]::after { content: '⌄'; margin-left: auto; }
body.toolbar-ready [data-topbar-action="bookmarks"] .reader-topbar-text { display: none; }

body.toolbar-ready .reader-topbar-value { font-variant-numeric: tabular-nums; }
body.toolbar-ready [data-topbar-action="font-down"],body.toolbar-ready [data-topbar-action="font-up"] { font-size: 14px; }
body.toolbar-ready .toolbar-icons .reader-topbar-direct .reader-topbar-text { display: none; }
body.toolbar-ready #menubar.toolbar-short-book .topbar-zone-b { width: var(--ui-topbar-book-compact-w); }
body.toolbar-ready #menubar.toolbar-tiny-book .topbar-zone-b { width: 88px; }
body.toolbar-ready .reader-topbar-overflow { flex: none; }
body.toolbar-ready .reader-topbar-overflow summary {
  display: flex; align-items: center; justify-content: center; gap: var(--ui-control-gap);
  height: var(--ui-icon-button-size); min-width: var(--ui-icon-button-size); padding: 6px; box-sizing: border-box;
  border: 1px solid transparent; line-height: var(--ui-button-line-height);
}
body.toolbar-ready .reader-topbar-overflow summary::after { display: none; }
.toolbar-more-chevron { width: 16px; height: 16px; flex: none; transform: none; }
body.toolbar-ready .reader-topbar-menu { z-index: var(--z-menubar); max-width: calc(100vw - 16px); }
body.toolbar-ready .reader-topbar-menu .reader-topbar-button { width: 100%; height: auto; justify-content: flex-start; }
body.toolbar-ready .reader-topbar-menu .reader-topbar-text { display: inline; }
.toolbar-global-overflow { display: flex; flex-direction: column; border-top: 1px solid var(--ui-border); padding-top: var(--ui-toolbar-gap); }
.toolbar-global-overflow .shell-view { text-align: left; }
.toolbar-restore, .toolbar-focus-exit {
  position: fixed; z-index: calc(var(--z-menubar) + 1); top: max(6px, env(safe-area-inset-top)); right: 10px;
  background: var(--ui-panel); border: 1px solid var(--ui-border); border-radius: var(--ui-button-radius); box-shadow: var(--ui-shadow-toolbar);
}
.toolbar-reveal-edge { position: fixed; top: 0; left: 0; right: 0; height: 5px; z-index: var(--z-menubar); }
.toolbar-reveal-edge[hidden] { display: none; }
body.toolbar-ready .toolbar-collapse { font-size: 20px; }
body.toolbar-floating:not(.toolbar-hidden) #reader-tool-view,
body.toolbar-floating:not(.toolbar-hidden) .reader-fold-panel { top: var(--ui-topbar-h); }
body.toolbar-ready #reader-panel .reader-tool-view { width: min(var(--ui-reader-aux-w), 100%); bottom: 0; }
/* 书籍、目录和折叠管理共享通高侧栏，窄屏以阅读区可用宽度为限。 */
body.toolbar-ready #reader-panel #reader-tool-view[data-active="documents"],
body.toolbar-ready #reader-panel #reader-tool-view[data-active="quick"],
body.toolbar-ready #reader-panel #reader-tool-view[data-active="toc"] { width: min(var(--ui-reader-sidebar-w), 100%); bottom: 0; }
body.toolbar-ready #reader-panel .reader-tool-view[data-active="width"],
body.toolbar-ready #reader-panel .reader-tool-view[data-active="theme"],
body.toolbar-ready #reader-panel .reader-tool-view[data-active="progress"] {
  bottom: auto; max-height: calc(100% - 8px); border: 1px solid var(--ui-border); border-radius: var(--ui-popover-radius);
}
.reader-width-presets, .reader-theme-view { display: flex; gap: var(--ui-control-gap); flex-wrap: wrap; }
.reader-progress-view input[type="range"] { width: 100%; accent-color: var(--ui-accent); }
body.toolbar-ready #reader-view-progress #reader-progress {
  position: static; width: auto; margin: 0; border: 0; padding: 0; box-shadow: none; background: transparent;
}
body.toolbar-ready #reader-view-progress #reader-progress .reader-progress-track { display: none; }
body.toolbar-ready #reader-view-progress #reader-progress-label { margin-inline: auto; }
body.reader-focus-active #reader-panel { width: 100% !important; max-width: none !important; left: 0; right: 0; top: 0; height: 100dvh; border: 0; }
body.reader-focus-active #stage,body.reader-focus-active #reader-resizer,
body.reader-focus-active #outline-panel,body.reader-focus-active #mdpanel,body.reader-focus-active #reader-tool-view,
body.reader-focus-active #minimap,body.reader-focus-active #dock,body.reader-focus-active #mobilebar,
body.reader-focus-active #hint,body.reader-focus-active .panel,body.reader-focus-active #batch-dock { display: none !important; }
/* 手机使用单行常用菜单；设置与收纳复用同一按钮移入更多。 */
@media (max-width: 900px) {
  body.toolbar-ready { --ui-topbar-h: var(--ui-mobile-topbar-h); }
  body.toolbar-ready #menubar { padding-inline: var(--ui-mobile-topbar-padding); gap: var(--ui-control-gap); }
  body.toolbar-ready #menubar .topbar-zone-a { flex: 1; min-width: 0; gap: var(--ui-control-gap); }
  body.toolbar-ready #menubar .mb-item,
  body.toolbar-ready #menubar .shell-view,
  body.toolbar-ready #menubar .reader-topbar-button,
  body.toolbar-ready #menubar .reader-topbar-overflow summary {
    display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
    min-width: var(--ui-touch-target); height: var(--ui-touch-target); min-height: var(--ui-touch-target);
    padding: 0 var(--ui-control-gap); letter-spacing: normal;
    font: var(--ui-weight-medium) var(--ui-font-size)/var(--ui-button-line-height) var(--ui-font);
  }
  body.toolbar-ready #menubar .shell-views { gap: 0; }
  body.toolbar-ready #menubar .shell-modes { flex: 1; justify-content: space-around; height: var(--ui-touch-target); }
  body.toolbar-ready #menubar .shell-modes .shell-view { height: var(--ui-touch-target); }
  body.toolbar-ready #menubar .shell-view[data-shell-view="split"] { display: none; }
  body.toolbar-ready #menubar #rm-manager-close {
    position: relative; width: var(--ui-mobile-return-w); gap: 2px; justify-content: flex-start;
    padding-left: 0; margin-right: var(--ui-control-gap); color: var(--ui-accent);
  }
  body.toolbar-ready #menubar #rm-manager-close::after {
    content: ''; position: absolute; right: 0; height: 16px; border-right: 1px solid var(--ui-border);
  }
  body.toolbar-ready #menubar #rm-manager-close > [aria-hidden] { display: flex; }
  body.toolbar-ready #menubar #rm-manager-close svg { width: var(--ui-icon-size); height: var(--ui-icon-size); }
  body.toolbar-ready #menubar .reader-topbar-menu .reader-topbar-button,
  body.toolbar-ready #menubar .reader-topbar-menu .shell-view,
  body.toolbar-ready #menubar .reader-topbar-menu .mb-item,
  body.toolbar-ready #menubar .profile-overflow-menu > .shell-view,
  body.toolbar-ready #menubar .profile-overflow-menu > .mb-item,
  body.toolbar-ready #menubar .toolbar-global-overflow .shell-view { width: 100%; justify-content: flex-start; padding-inline: var(--ui-control-gap); text-align: left; }
  body.toolbar-ready .toolbar-global-overflow { border-top: 0; border-bottom: 1px solid var(--ui-border); padding-top: 0; padding-bottom: var(--ui-toolbar-gap); }
  body.toolbar-ready #menubar .reader-topbar-menu .reader-topbar-button[hidden] { display: none !important; }
  body.toolbar-ready .toolbar-restore,body.toolbar-ready .toolbar-focus-exit { min-height: var(--ui-touch-target); }
}

.toolbar-theme-presets { display: flex; gap: var(--ui-control-gap); }
.toolbar-theme-presets[hidden] { display: none; }

/* 已审核统一菜单：相同动作共用图标，子菜单与分隔线不改变业务状态。 */
.mm-menu-separator { display: inline-block; flex: none; width: 1px; height: var(--icon-size); margin-inline: var(--ui-control-gap); background: var(--ui-border); }
.mm-menu-separator[hidden] { display: none !important; }
.mm-menu-divider { margin-block: var(--ui-control-gap); border-top: 1px solid var(--ui-border); }
.mm-action-menu { position: fixed; z-index: max(calc(var(--z-ctxmenu) + 2), calc(var(--reader-selection-z) + 2), calc(var(--z-menubar) + 2)); box-sizing: border-box; width: var(--node-menu-list-width); overflow: auto; overscroll-behavior: contain; padding: var(--node-menu-padding); border: 1px solid var(--ui-border); border-radius: var(--ui-popover-radius); background: var(--ui-panel); color: var(--ui-text); box-shadow: var(--ui-shadow); font: var(--ui-font-size)/1.5 var(--ui-font); }
.mm-action-menu[hidden] { display: none; }
.mm-action-menu-head { display: flex; align-items: center; justify-content: space-between; padding-left: var(--node-menu-padding); border-bottom: 1px solid var(--ui-border); margin-bottom: var(--ui-control-gap); }
.mm-action-menu-head strong { font-weight: var(--ui-weight-medium); }
.mm-action-menu button { color: inherit; background: transparent; border: 0; border-radius: var(--ui-button-radius); font: inherit; cursor: pointer; }
.mm-action-menu-close { display: grid; place-items: center; width: var(--ui-icon-button-size); min-height: var(--ui-icon-button-size); }
.mm-action-menu-item { display: flex; width: 100%; align-items: center; gap: var(--ui-control-gap); text-align: left; min-height: var(--ui-icon-button-size); padding: var(--ui-control-gap); }
.mm-action-menu button:hover:not(:disabled) { background: var(--ui-hover-bg); }
.mm-action-menu button:focus-visible { outline: var(--ui-focus-width) solid var(--ui-accent); outline-offset: -2px; }
.mm-action-menu .mm-icon { width: var(--icon-size); height: var(--icon-size); flex: none; }
.mm-action-menu .danger { color: var(--ui-danger); }
.mm-action-menu button:disabled { opacity: var(--ui-disabled-opacity); cursor: not-allowed; }
#menubar .mb-item, #menubar .shell-view { display: inline-flex; align-items: center; gap: var(--ui-control-gap); }
/* 菜单项逐行参与宽度计算，避免 inline-flex 将全部按钮当作一长行。 */
.dropdown .di { display: flex; align-items: center; gap: var(--ui-control-gap); }
#menubar .mm-icon, .dropdown .di .mm-icon { width: var(--icon-size); height: var(--icon-size); flex: none; }
#menubar .mb-item, #menubar .shell-view { white-space: nowrap; }
#menubar .toolbar-icons .shell-label { display: none; }
#menubar.toolbar-icons > .topbar-zone-a .shell-label { display: none; }
#menubar .toolbar-global-overflow .shell-label,
#menubar .profile-overflow-menu .shell-label { display: inline; }
#menubar .toolbar-global-overflow .mb-item,
#menubar .profile-overflow-menu .mb-item,
#menubar .profile-overflow-menu .shell-view { width: 100%; justify-content: flex-start; }
.menu-after-divider { border-bottom: 1px solid var(--ui-border) !important; border-radius: 0 !important; padding-bottom: var(--ui-control-gap) !important; margin-bottom: var(--ui-control-gap); }
.toolbar-icon-only .toolbar-control-label { display: none; }
.profile-overflow-menu .toolbar-icon-only .toolbar-control-label,
.reader-topbar-menu .toolbar-icon-only .toolbar-control-label { display: inline; }
body.toolbar-ready .reader-topbar-menu .reader-tools-overflow { width: 100%; }
body.toolbar-ready .reader-topbar-menu .reader-tools-overflow > summary { justify-content: flex-start; }
body.toolbar-ready .reader-topbar-menu .reader-tools-overflow > .reader-topbar-menu { position: static; width: auto; max-height: none; border: 0; box-shadow: none; }
body.toolbar-ready .reader-topbar-menu { max-height: calc(100dvh - var(--ui-topbar-h) - 16px); overflow-y: auto; }
body.toolbar-ready [data-topbar-action="font-down"] .reader-topbar-value, body.toolbar-ready [data-topbar-action="font-up"] .reader-topbar-value { font: inherit; }
@media (pointer: coarse) { .mm-action-menu button { min-height: var(--ui-touch-target); } .mm-action-menu-close { min-width: var(--ui-touch-target); } }
@media (max-width: 900px) {
  body.toolbar-ready #menubar .mm-menu-separator { display: none; }
  body.toolbar-ready #menubar .toolbar-global-overflow .mb-item,
  body.toolbar-ready #menubar .profile-overflow-menu > .mb-item,
  body.toolbar-ready #menubar .profile-overflow-menu > .shell-view { display: flex; min-height: var(--ui-touch-target); }
  body.toolbar-ready #menubar .shell-view > .mm-icon { width: var(--ui-icon-size); height: var(--ui-icon-size); }
  body.toolbar-ready #menubar .topbar-zone-a .shell-label { display: none; }
  body.toolbar-ready #menubar .toolbar-global-overflow .shell-label,
  body.toolbar-ready #menubar .profile-overflow-menu .shell-label { display: inline; }
}

/* Argon 第二阶段：保存、模式与核心任务分区；宽度不足逐项收纳。 */
.save-status { display:inline-flex; align-items:center; gap:var(--ui-control-gap); max-width:150px; min-height:32px; padding:4px 8px; border:1px solid var(--ui-border); border-radius:var(--ui-button-radius); background:var(--ui-panel); color:var(--ui-muted); font:12px/1.4 var(--ui-font); }
.save-status[hidden], .learning-split[hidden] { display:none!important; }
.save-status-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.save-status-dot { width:6px; height:6px; border-radius:50%; background:var(--ui-accent); flex:none; }
.save-status[data-warning="true"] { color:var(--ui-danger); }
.save-status[data-warning="true"] .save-status-dot { background:currentColor; }
.learning-split { display:inline-flex; flex:none; align-items:center; border:1px solid var(--ui-border); border-radius:var(--ui-button-radius); }
.learning-split .learning-more { border-left:1px solid var(--ui-border)!important; min-width:26px!important; padding-inline:3px!important; }
/* 收进更多后仍保留一行两个独立按钮，避免每个按钮继承整行宽度。 */
#menubar .profile-overflow-menu .learning-split { width:100%; }
#menubar .profile-overflow-menu .learning-split .review-reminder { flex:1; min-width:0; width:auto!important; }
#menubar .profile-overflow-menu .learning-split .learning-more { flex:none; width:var(--ui-touch-target)!important; min-width:var(--ui-touch-target)!important; }
body.toolbar-ready #menubar:not(.toolbar-icons) .mindmap-topbar-tools .shell-view > span,
body.toolbar-ready #menubar:not(.toolbar-icons) .shell-modes .shell-view > span { display:inline; }
.file-menu-group { padding:8px 10px 3px; color:var(--ui-muted); font-size:11px; border-top:1px solid var(--ui-border); }
.file-menu-group:first-child { border-top:0; }
@media(max-width:900px) {
  .save-status { max-width:24px; min-width:24px; padding:0; min-height:44px; justify-content:center; border:0; background:transparent; }
  .save-status-label { display:none; }
  .learning-split .review-reminder { min-width:44px; }
}

/* 非脑图删除操作使用自己的恢复接口，不回退整个 Model 历史。 */
.action-toast { position:fixed; z-index:20000; left:50%; bottom:calc(24px + env(safe-area-inset-bottom)); transform:translateX(-50%); display:flex; flex-wrap:wrap; align-items:center; gap:10px; width:max-content; max-width:calc(100% - 24px); padding:12px 16px; box-sizing:border-box; border:1px solid var(--ui-border); border-radius:var(--ui-button-radius); background:var(--ui-panel); color:var(--ui-text); box-shadow:var(--ui-shadow); font:13px/1.5 var(--ui-font); }
.action-toast button { min-height:32px; border:0; background:transparent; color:var(--ui-accent); cursor:pointer; font:inherit; }
.action-toast button:disabled { opacity:.6; }
@media(max-width:900px) { .action-toast { bottom:calc(76px + env(safe-area-inset-bottom)); } .action-toast button { min-height:44px; } }

@media(min-width:901px) {
  html:not([data-app-mode="mindmap"]) body.toolbar-ready #menubar.has-menu-profile .shell-modes > button,
  html:not([data-app-mode="mindmap"]) body.toolbar-ready #menubar.has-menu-profile .mindmap-topbar-tools > button[data-shell-view],
  html:not([data-app-mode="mindmap"]) body.toolbar-ready #menubar.has-menu-profile .mindmap-topbar-tools > #ai-toggle,
  html:not([data-app-mode="mindmap"]) body.toolbar-ready #menubar.has-menu-profile .topbar-zone-a > [data-command="view.manager"] { width:auto; font-size:12px; padding-inline:7px; gap:5px; }
  html:not([data-app-mode="mindmap"]) body.toolbar-ready #menubar.has-menu-profile .shell-modes .shell-label,
  html:not([data-app-mode="mindmap"]) body.toolbar-ready #menubar.has-menu-profile .mindmap-topbar-tools > button .shell-label,
  html:not([data-app-mode="mindmap"]) body.toolbar-ready #menubar.has-menu-profile .topbar-zone-a > [data-command="view.manager"] .shell-label { display:inline; }
}

.mm-action-menu-reason { display:block; font-size:11px; color:var(--ui-muted); line-height:1.4; margin-top:3px; }
