/* ==================================================================
   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 .toolbar-global-overflow .shell-view { width: 100%; justify-content: flex-start; padding-inline: var(--ui-control-gap); }
  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, .dropdown .di { display: inline-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 { display: inline; }
#menubar .toolbar-global-overflow .mb-item { 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; }
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 { 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 { display: inline; }
}
