/* ==================================================================
   mindmap5.3 · css/manager-outline.css —— 阅读集管理器右栏：大纲预览
   只负责 #rm-right 内部（栏头工具 / 大纲树 / 五种状态 / 底部操作条）；
   三栏骨架、抽屉与手机分层由 css/manager.css 负责。
   颜色 / 圆角 / 阴影 / 动画时长一律取自 variables.css 令牌，不新增魔法值；
   断点：≤900 本栏为层 3 全屏（触控目标 ≥44px），粗指针常显「打开并定位」。
   ================================================================== */

/* 右栏底色与 05 原型 / 阅读集侧栏一致（骨架底色由本模块收口） */
#rm-right { background: var(--ui-panel); }

/* ---------- ≤900 层 3 全屏顶栏（核心控制显隐，本模块保证可用） ---------- */
.rmo-mobtop {
  display: none;
  flex: none;
  height: var(--menubar-h);
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--ui-border);
}
.rmo-mobback { flex: none; }
.rmo-mobtitle {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ui-text);
  font: 650 14px/1.5 var(--ui-font);
}

/* ---------- 栏头：动态标题 + 刷新/关闭 + 搜索 + 展开层级 ---------- */
.rmo-head {
  flex: none;
  display: grid;
  gap: 8px;
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--ui-border);
}
.rmo-title-row {
  min-height: var(--ui-panel-header-h);
  display: flex;
  align-items: center;
  gap: 8px;
}
.rmo-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ui-text);
  font: 650 14px/1.5 var(--ui-font);
}
.rmo-iconbtn {
  appearance: none;
  width: var(--ui-icon-button-size);
  height: var(--ui-icon-button-size);
  flex: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--ui-button-radius);
  background: transparent;
  color: var(--ui-text);
  cursor: pointer;
}
.rmo-iconbtn:hover:not(:disabled), .rmo-iconbtn:active:not(:disabled) { color: var(--ui-hover-text); background: var(--ui-hover-bg); }
.rmo-ic { width: var(--ui-icon-size); height: var(--ui-icon-size); flex: none; display: block; }

.rmo-search {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--ui-input-h);
  padding: 0 9px;
  border: 1px solid var(--ui-input-border);
  border-radius: var(--ui-input-radius);
  background: var(--ui-input-bg);
  color: var(--ui-muted);
}
#reading-manager .rmo-search input:not([type=checkbox]):not([type=radio]) {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  min-height: 0;
  padding: 7px 0;
  outline: none;
  background: transparent;
  color: var(--ui-text);
  font: 400 12px/1.5 var(--ui-font);
}
.rmo-search .rmo-ic { width: 15px; height: 15px; }
.rmo-search:focus-within { border-color: var(--ui-accent); outline: var(--ui-focus-width) solid var(--ui-accent); outline-offset: var(--ui-focus-offset); box-shadow: var(--ui-focus); }
#reading-manager .rmo-search input:focus-visible { outline: none; box-shadow: none; }
.rmo-search input::placeholder { color: var(--ui-muted); }

.rmo-lvl {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.rmo-lvlbtn {
  appearance: none;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--ui-pill-radius);
  background: transparent;
  color: var(--ui-text);
  font: 400 11px/1.4 var(--ui-font);
  cursor: pointer;
}
.rmo-lvlbtn.on {
  color: var(--ui-accent);
  border-color: transparent;
  background: var(--ui-pressed-bg);
}
.rmo-lvlbtn:hover:not(:disabled) { background: var(--ui-hover-bg); color: var(--ui-hover-text); }
.rmo-collapse-all { margin-left: auto; }
.rmo-copy { color: var(--ui-accent); }

/* ---------- 加载提示行（300ms 延迟显示，防闪烁） ---------- */
.rmo-loading {
  flex: none;
  margin: 0;
  padding: 7px 14px 0;
  color: var(--ui-muted);
  font: 600 11.5px/1.4 var(--ui-font);
}
.rmo-loading[hidden] { display: none; }

/* ---------- 树滚动容器（宿主滚动持久化约定 .rm-col-scroll） ---------- */
.rmo-body { padding: var(--ui-panel-body-padding); scrollbar-width: thin; overflow-x: auto; }
.rmo-body.is-map-outline { overflow-x: hidden; overscroll-behavior: contain; }
.rmo-tree {
  width: max-content;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rmo-tree:focus-visible { outline: var(--ui-focus-width) solid var(--ui-accent); outline-offset: -2px; box-shadow: var(--ui-focus); }

/* 大纲行：缩进 = depth（每级 16px），层级字号/字重递减（--d 从 0 起） */
.rmo-treeitem {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: var(--ui-control-h);
  padding: 9px 8px 9px calc(6px + var(--d, 0) * 16px);
  border: 0;
  border-radius: var(--ui-button-radius);
  background: transparent;
  color: var(--ui-text);
  cursor: pointer;
  text-align: left;
  font-family: var(--ui-font);
  font-weight: max(400, calc(650 - var(--d, 0) * 100));
  font-size: max(12px, calc(13px - var(--d, 0) * .4px));
  line-height: 1.6;
  box-sizing: border-box;
}
.rmo-treeitem:hover { background: var(--ui-hover-bg); }
.rmo-treeitem.on { background: var(--ui-pressed-bg); color: var(--ui-pressed-text); }
.rmo-treeitem:focus-visible { outline: var(--ui-focus-width) solid var(--ui-accent); outline-offset: -2px; box-shadow: var(--ui-focus); }
.rmo-treeitem .rmo-tt {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 分支 caret：仅有子节点的行显示；closed 折叠态旋转 */
.rmo-caret {
  appearance: none;
  width: 16px;
  height: 16px;
  flex: none;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--ui-button-radius);
  background: transparent;
  color: var(--ui-muted);
  cursor: pointer;
  transition: transform var(--ui-motion-fast);
}
.rmo-caret .rmo-ic { width: 12px; height: 12px; }
.rmo-caret.closed { transform: rotate(-90deg); }
.rmo-tspace { width: 16px; height: 16px; flex: none; }

/* 悬停项尾「打开并定位」；粗指针常显（无 hover） */
.rmo-locate {
  appearance: none;
  flex: none;
  visibility: hidden;
  min-height: 26px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-button-radius);
  background: var(--ui-panel);
  color: var(--ui-accent);
  font: 400 11px/1.4 var(--ui-font);
  cursor: pointer;
}
.rmo-treeitem:hover .rmo-locate,
.rmo-treeitem:focus-within .rmo-locate { visibility: visible; }
.rmo-locate:hover { border-color: var(--ui-accent); }

/* 搜索无结果 / 加载更多 / 截断说明 */
.rmo-none {
  padding: 18px 10px;
  text-align: center;
  color: var(--ui-muted);
  font: 500 11.5px/1.6 var(--ui-font);
}
.rmo-more {
  appearance: none;
  display: block;
  width: calc(100% - 16px);
  margin: 6px auto 2px;
  min-height: var(--ui-control-h);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-button-radius);
  background: var(--ui-panel);
  color: var(--ui-text);
  font: 400 12px/1.5 var(--ui-font);
  cursor: pointer;
}
.rmo-more:hover { color: var(--ui-text); border-color: var(--ui-accent); }
.rmo-truncated {
  margin: 4px 0 0;
  padding: 0 8px;
  text-align: center;
  color: var(--ui-muted);
  font: 500 10.5px/1.5 var(--ui-font);
}

/* ---------- 空态卡（未选中 / PDF 无大纲 / 未缓存 / 失败） ---------- */
.rmo-empty {
  margin: auto;
  max-width: 320px;
  padding: 28px 14px;
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  color: var(--ui-muted);
}
.rmo-empty-ic {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--ui-border);
  border-radius: var(--ui-dialog-radius);
  background: var(--ui-bg);
  color: var(--ui-muted);
}
.rmo-empty-ic .rmo-ic { width: 24px; height: 24px; }
.rmo-empty-title { margin: 2px 0 0; color: var(--ui-text); font: 650 14px/1.5 var(--ui-font); }
.rmo-empty-desc { margin: 0; font: 500 12px/1.6 var(--ui-font); overflow-wrap: anywhere; }
.rmo-empty-btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- 通用按钮 / 底部上下文操作条 ---------- */
.rmo-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: var(--ui-control-h);
  padding: var(--ui-button-padding);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-button-radius);
  background: var(--ui-panel);
  color: var(--ui-text);
  font: 400 13px/1.4 var(--ui-font);
  cursor: pointer;
  white-space: nowrap;
}
.rmo-btn:hover:not(:disabled) { color: var(--ui-hover-text); background: var(--ui-hover-bg); }
.rmo-btn:disabled { opacity: var(--ui-disabled-opacity); cursor: not-allowed; }
.rmo-btn-primary {
  color: var(--ui-primary-text);
  border-color: var(--ui-accent);
  background: var(--ui-accent);
}
.rmo-btn-primary:hover:not(:disabled) { color: var(--ui-primary-text); background: var(--ui-accent); filter: brightness(1.06); }

.rmo-foot {
  flex: none;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--ui-border);
}
.rmo-foot:empty { display: none; border: 0; padding: 0; }
.rmo-export-wrap { position: relative; display: inline-flex; }

/* 导出 ▾ 下拉（向上弹出） */
.rmo-menu {
  position: absolute;
  z-index: var(--z-ctxmenu);
  bottom: calc(100% + 6px);
  right: 0;
  min-width: var(--ui-menu-min-w);
  padding: var(--ui-menu-padding);
  display: grid;
  gap: 2px;
  border: 1px solid var(--ui-menu-border);
  border-radius: var(--ui-menu-radius);
  background: var(--ui-menu-bg);
  box-shadow: var(--ui-shadow);
}
.rmo-menu[hidden] { display: none; }
.rmo-menuitem {
  appearance: none;
  text-align: left;
  padding: 7px 9px;
  min-height: var(--ui-control-h);
  border: 0;
  border-radius: var(--ui-button-radius);
  background: transparent;
  color: var(--ui-text);
  font: 400 12px/1.5 var(--ui-font);
  cursor: pointer;
}
.rmo-menuitem:hover:not(:disabled) { background: var(--ui-hover-bg); color: var(--ui-hover-text); }
.rmo-menuitem:disabled { color: var(--ui-muted); cursor: not-allowed; opacity: var(--ui-disabled-opacity); }

/* ---------- 触控可用性（粗指针常显定位按钮） ---------- */
@media (pointer: coarse) {
  .rmo-locate { visibility: visible; }
  .rmo-caret { width: var(--ui-touch-target); height: var(--ui-touch-target); }
  .rmo-locate { min-height: var(--ui-touch-target); }
}

/* ---------- ≤900：层 3 全屏布局与 44px 触控目标 ---------- */
@media (max-width: 900px) {
  .rmo-mobtop { display: flex; }
  .rmo-head { padding: 0 10px 8px; }
  .rmo-search { min-height: var(--ui-touch-target); }
  .rmo-body { padding: 8px 10px calc(10px + var(--safe-area-bottom)); overflow-x: hidden; }
  .rmo-treeitem { min-height: var(--ui-touch-target); }
  .rmo-caret { width: var(--ui-touch-target); height: var(--ui-touch-target); }
  .rmo-locate { min-height: var(--ui-touch-target); padding: 0 10px; }
  .rmo-btn { height: var(--ui-touch-target); }
  .rmo-iconbtn { width: var(--ui-touch-target); height: var(--ui-touch-target); }
  .rmo-lvlbtn { min-height: var(--ui-touch-target); padding: 0 10px; }
  .rmo-foot { padding: 8px 10px calc(8px + var(--safe-area-bottom)); }
}

/* ---------- 动画弱化偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .rmo-caret,
  .rmo-btn,
  .rmo-menu,
  .rmo-treeitem { transition-duration: 0ms; }
}

/* 管理器在手机上只保留一个返回入口。 */
@media (max-width: 900px) { .rmo-head .rmo-close { display: none; } }
