/* =============================================================
 *  WebCAD 界面样式
 * ============================================================= */
:root {
  /* ---- 默认：深色界面（与深色图纸底色配套） ---- */
  --bg: #14181e;
  --panel: #1b2027;
  --panel2: #212730;
  --border: #333b46;
  --border2: #2a313a;
  --text: #e6eaef;
  --text2: #aab3bf;
  --text3: #7c8593;
  --accent: #3b9dff;
  --accent-soft: #22354d;
  --accent-soft-br: #2f5d8c;
  --hover: #262d36;
  --sel: #3b9dff;
  --danger: #ff6b60;
  --ok: #3ecf72;
  --input: #12161c;
  --input2: #14181f;
  --canvas-bg: #11151c;
  --grad-top: linear-gradient(180deg, #1e242c, #191f26);
  --thumb: #3d4653;
  --snap: #ffb84d;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  --h-top: 40px;
  --h-ribbon: 78px;
  --h-status: 26px;
  --w-left: 236px;
  --w-right: 268px;
  --h-log: 132px;
}

/* ---- 浅色界面（点“界面皮肤”切换） ---- */
body.ui-light {
  --bg: #f2f3f5;
  --panel: #ffffff;
  --panel2: #fafbfc;
  --border: #d9dde3;
  --border2: #e8ebef;
  --text: #1f2329;
  --text2: #646a73;
  --text3: #8f959e;
  --accent: #0a84ff;
  --accent-soft: #e8f2ff;
  --accent-soft-br: #c3ddfb;
  --hover: #eef0f3;
  --sel: #0a84ff;
  --danger: #e0483c;
  --ok: #2fa84f;
  --input: #ffffff;
  --input2: #ffffff;
  --canvas-bg: #ffffff;
  --grad-top: linear-gradient(180deg, #fbfcfd, #eef1f5);
  --thumb: #cfd4da;
  --snap: #c98600;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  user-select: none;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------------- 标题栏 ---------------- */
.topbar {
  height: var(--h-top);
  background: var(--grad-top);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  flex: none;
}

.logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .3px;
}

.logo svg {
  width: 20px;
  height: 20px;
}

.logo .sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text3);
  margin-left: 2px;
}

.topbar .spacer {
  flex: 1;
}

.tbtn {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.tbtn:hover {
  background: var(--hover);
}

/* ---------------- Ribbon ---------------- */
.ribbon {
  flex: none;
  min-height: var(--h-ribbon);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
}

.ribbon::-webkit-scrollbar {
  height: 6px;
}

.ribbon::-webkit-scrollbar-thumb {
  background: var(--thumb);
  border-radius: 3px;
}

.rgroup {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border2);
  padding: 2px 6px 4px;
  min-width: 0;
}

.rtitle {
  font-size: 10px;
  color: var(--text3);
  text-align: center;
  padding: 2px 0 3px;
  letter-spacing: .5px;
}

.ritems {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-content: flex-start;
}

.rbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 52px;
  height: 50px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  padding: 2px;
}

.rbtn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft-br);
}

.rbtn:active {
  background: var(--accent-soft-br);
  color: var(--text);
}

.rbtn span {
  font-size: 10px;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50px;
}

.ic {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------- 主体 ---------------- */
.body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.left,
.right {
  width: var(--w-left);
  background: var(--panel);
  flex: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.left {
  border-right: 1px solid var(--border);
  width: var(--w-left);
}

.right {
  border-left: 1px solid var(--border);
  width: var(--w-right);
}

.left::-webkit-scrollbar,
.right::-webkit-scrollbar {
  width: 8px;
}

.left::-webkit-scrollbar-thumb,
.right::-webkit-scrollbar-thumb {
  background: var(--thumb);
  border-radius: 4px;
}

.psec {
  border-bottom: 1px solid var(--border2);
}

.phead {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--panel2);
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border2);
}

.phead .sp {
  flex: 1;
}

.pbody {
  padding: 8px 10px;
}

/* 图层 */
.lay {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.lay:hover {
  background: var(--hover);
}

.lay.active {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-soft-br);
}

.lay .dot {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid var(--border);
  flex: none;
}

.lay .lname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.lmini {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  color: var(--text2);
  padding: 0 2px;
  line-height: 1;
}

.lmini:hover {
  color: var(--accent);
}

.lrow {
  display: flex;
  gap: 5px;
  margin-top: 7px;
}

.lrow button,
.lrow select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--input);
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text);
}

.lrow button:hover {
  background: var(--hover);
}

/* 捕捉 */
.osgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 6px;
}

.osl {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
}

.osl input {
  margin: 0;
}

.frow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text2);
}

.frow select {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  background: var(--input);
  color: var(--text);
}

/* 画布区 */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--canvas-bg);
  position: relative;
}

.canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: crosshair;
}

/* 命令行区域 */
.bottom {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}

.logbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--border2);
  background: var(--panel2);
  font-size: 11px;
  color: var(--text3);
}

.logbar .sp {
  flex: 1;
}

.logbar button {
  border: 1px solid var(--border);
  background: var(--input);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text2);
}

.logbar button:hover {
  background: var(--hover);
}

#log {
  height: var(--h-log);
  overflow-y: auto;
  padding: 4px 10px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text2);
  background: var(--input2);
}

#log div {
  white-space: pre-wrap;
  word-break: break-all;
}

.cmdrow {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-top: 1px solid var(--border2);
  background: var(--panel);
}

#hint {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}

#cmdInput {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: Consolas, "Courier New", monospace;
  outline: none;
  color: var(--text);
  background: var(--input);
}

#cmdInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 157, 255, .18);
}

/* ---------------- 状态栏 ---------------- */
.status {
  height: var(--h-status);
  flex: none;
  background: var(--grad-top);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 11px;
  color: var(--text2);
}

.status .sp {
  flex: 1;
}

.sbtn {
  border: 1px solid var(--border);
  background: var(--input);
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text2);
  line-height: 18px;
}

.sbtn:hover {
  background: var(--hover);
}

.sbtn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#statusSnap {
  color: var(--snap);
  font-weight: 700;
  min-width: 40px;
}

.sep {
  width: 1px;
  height: 14px;
  background: var(--border);
}

/* ---------------- 属性面板 ---------------- */
.psect {
  border-bottom: 1px solid var(--border2);
}

.ph {
  padding: 7px 10px;
  background: var(--panel2);
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  border-bottom: 1px solid var(--border2);
  letter-spacing: .5px;
}

.prow {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  min-height: 26px;
}

.prow label {
  width: 58px;
  flex: none;
  font-size: 11px;
  color: var(--text3);
}

.prow select,
.prow input.pnum {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  background: var(--input);
  color: var(--text);
  height: 22px;
}

.prow select:focus,
.prow input.pnum:focus {
  outline: none;
  border-color: var(--accent);
}

.pval {
  flex: 1;
  font-size: 11px;
  color: var(--text);
  font-family: Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ptip {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text3);
  line-height: 1.6;
}

.pbtn {
  flex: 1;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  cursor: pointer;
}

.pbtn:hover {
  filter: brightness(1.06);
}

/* ---------------- 右键菜单 ---------------- */
#ctxmenu {
  position: absolute;
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
  z-index: 999;
  min-width: 140px;
}

.citem {
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.citem:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.csep {
  height: 1px;
  background: var(--border2);
  margin: 3px 0;
}

/* 隐藏控件 */
.hidden {
  display: none !important;
}

/* 全屏画布由 v1.8 的 body.layout-zen 接管（见文末「界面布局优化」），
   此处保留旧类名仅为兼容历史脚本，不再附加隐藏规则。 */

/* 忙碌浮层（打开 DWG 时） */
.busy {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 24, 30, 0.45);
}

.busy-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 16px 22px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width:1200px) {
  :root {
    --w-right: 232px;
    --w-left: 208px;
  }
}

/* =============================================================
 *  可拖动 / 可缩放面板（dock.js）
 * ============================================================= */
.left,
.right,
.bottom,
.ribbon {
  position: relative;
}

/* 标题把手 */
.dockbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  background: var(--panel2);
  border-bottom: 1px solid var(--border2);
  cursor: grab;
  flex: none;
  user-select: none;
}

.dockbar:active {
  cursor: grabbing;
}

.dockbar .dbtitle {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: .5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dockbar .dbtn {
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text2);
  border-radius: 3px;
  font-size: 10px;
  line-height: 14px;
  padding: 0 4px;
  cursor: pointer;
  flex: none;
}

.dockbar .dbtn:hover {
  background: var(--hover);
  color: var(--accent);
}

/* 功能区用竖排把手（横向滚动时固定在最左） */
.dockbar-v {
  position: sticky;
  left: 0;
  z-index: 5;
  flex-direction: column;
  width: 18px;
  border-bottom: none;
  border-right: 1px solid var(--border2);
  padding: 2px 0;
  gap: 3px;
}

.dockbar-v .dbtitle {
  writing-mode: vertical-rl;
  font-size: 10px;
  flex: none;
  letter-spacing: 1px;
}

/* 分隔条：拖动改大小 */
.splitter {
  position: absolute;
  z-index: 20;
  background: transparent;
}

.splitter:hover,
.splitter.on {
  background: var(--accent);
  opacity: .55;
}

.sp-r {
  top: 0;
  bottom: 0;
  right: -3px;
  width: 6px;
  cursor: ew-resize;
}

.sp-l {
  top: 0;
  bottom: 0;
  left: -3px;
  width: 6px;
  cursor: ew-resize;
}

.sp-t {
  left: 0;
  right: 0;
  top: -3px;
  height: 6px;
  cursor: ns-resize;
}

.sp-b {
  left: 0;
  right: 0;
  bottom: -3px;
  height: 6px;
  cursor: ns-resize;
}

/* 折叠 */
.left.folded,
.right.folded {
  width: 30px !important;
  overflow: hidden;
}

.left.folded .dbtitle,
.right.folded .dbtitle {
  display: none;
}

.bottom.folded #log {
  display: none;
}

.bottom.folded .logbar {
  border-bottom: none;
}

.ribbon.folded {
  height: 24px !important;
  min-height: 0;
  overflow: hidden;
}

.ribbon.folded .rgroup {
  display: none;
}

.ribbon.folded .dockbar-v {
  width: 100%;
  flex-direction: row;
  border-right: none;
  height: 24px;
  align-items: center;
  padding: 0 6px;
}

.ribbon.folded .dockbar-v .dbtitle {
  writing-mode: horizontal-tb;
}

/* 浮动窗口 */
.floating {
  position: fixed !important;
  z-index: 800;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.floating .splitter {
  display: none;
}

.floating .dockbar {
  cursor: move;
}

.dockrs {
  display: none;
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 30;
}

.floating .dockrs {
  display: block;
}

.dockrs::after {
  content: '';
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text3);
  border-bottom: 2px solid var(--text3);
}

.dockbody {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.left,
.right {
  overflow: hidden;
}

.left>.dockbody,
.right>.dockbody {
  overflow-y: auto;
  overflow-x: hidden;
}

.left>.dockbody::-webkit-scrollbar,
.right>.dockbody::-webkit-scrollbar,
.dockbody::-webkit-scrollbar {
  width: 8px;
}

.left>.dockbody::-webkit-scrollbar-thumb,
.right>.dockbody::-webkit-scrollbar-thumb,
.dockbody::-webkit-scrollbar-thumb {
  background: var(--thumb);
  border-radius: 4px;
}

/* 浮动后的命令历史：历史区跟着窗口一起伸缩 */
.bottom.floating #log {
  height: auto;
  flex: 1;
  min-height: 60px;
}

body.dragging {
  cursor: default;
}

body.dragging * {
  cursor: inherit !important;
}

/* ===== 自动保存状态指示 ===== */
.savestate {
  color: var(--text3);
  white-space: nowrap;
  padding-right: 4px;
}

.savestate.bad {
  color: var(--danger);
  font-weight: 600;
}

/* ===== 全局错误提示条（脚本异常不再白屏无声） ===== */
.errbar {
  position: fixed;
  z-index: 99999;
  top: 6px;
  left: 12px;
  right: 12px;
  padding: 8px 12px;
  max-height: 120px;
  overflow: hidden;
  background: #5a1e1a;
  color: #ffe3e0;
  border: 1px solid var(--danger);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  font: 12px/1.6 monospace;
  pointer-events: none;
}

body.ui-light .errbar {
  background: #ffe9e7;
  color: #7a1d16;
}

/* =============================================================
 *  触屏 / 移动端：画布手势由应用自己处理，禁用浏览器默认手势
 * ============================================================= */
#cv {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 820px) {
  :root {
    --h-ribbon: 64px;
    --h-log: 104px;
    --h-status: 24px;
  }
  /* 窄屏让位给绘图区；功能仍可从功能区 / 命令行调用 */
  .left,
  .right {
    display: none;
  }
  .topbar .sub {
    display: none;
  }
  .topbar {
    padding: 0 8px;
    gap: 6px;
  }
  .tbtn {
    padding: 5px 8px;
  }
  .ribbon {
    min-height: var(--h-ribbon);
  }
  .status #statusCoord,
  .status #statusSnap,
  .status .sep {
    display: none;
  }
  .cmdrow input {
    font-size: 15px;   /* iOS 输入框聚焦时不自动放大页面 */
  }
  .ptip {
    font-size: 11px;
  }
  .modal-box {
    padding: 14px;
  }
}

/* =============================================================
 *  高清 PNG 导出对话框
 * ============================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .55);
}
.modal.hidden {
  display: none !important;
}
.modal-box {
  width: min(380px, calc(100vw - 32px));
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  box-shadow: var(--shadow-lg);
}
.modal-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.mrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  font-size: 13px;
}
.mrow > label:first-child {
  width: 68px;
  flex: none;
  color: var(--text2);
}
.mrow select {
  flex: 1;
  min-width: 0;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 13px;
}
.chk {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text2);
  cursor: pointer;
}
.modal-tip {
  color: var(--text3);
  font-size: 12px;
  margin: 14px 0 6px;
}
.modal-btns {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.mbtn {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
}
.mbtn:hover {
  background: var(--hover);
}
.mbtn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.mbtn.primary:hover {
  filter: brightness(1.1);
}

/* =============================================================
 *  v1.8 界面布局优化 —— 让绘图区尽量大
 *  三种布局：layout-classic（v1.7 原样）/ layout-focus（默认）/ layout-zen（全屏）
 *  关键：把左右面板、命令历史、状态栏从 flex 流里拿出来，
 *        画布因此吃到整个窗口，需要时再用边缘标签唤出。
 * ============================================================= */
:root {
  --glass: rgba(27, 32, 39, .93);
  --glass-soft: rgba(27, 32, 39, .80);
  --glass-br: rgba(255, 255, 255, .10);
}

body.ui-light {
  --glass: rgba(255, 255, 255, .95);
  --glass-soft: rgba(255, 255, 255, .84);
  --glass-br: rgba(0, 0, 0, .10);
}

/* ---------- 功能区高度修正（v1.7 遗留 bug） ----------
   .rgroup 默认 flex-shrink:1 + min-width:0，被挤压后 .ritems 里的按钮
   会竖着堆 5~6 行，功能区实测高达 284px（配置值只有 78px），
   把画布高度吃掉两百多像素。改成按内容宽度排列、横向滚动。 */
.ribbon {
  align-items: stretch;
}

.rgroup {
  flex: 0 0 auto;
}

.ritems {
  flex-wrap: nowrap;
}

/* ---------- 布局分段控件 ---------- */
.layoutseg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  flex: none;
  background: var(--input);
}

.lseg {
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 11px;
  padding: 4px 11px;
  cursor: pointer;
  white-space: nowrap;
}

.lseg:last-child {
  border-right: 0;
}

.lseg:hover {
  background: var(--hover);
  color: var(--text);
}

.lseg.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- 全屏模式的悬浮退出胶囊 ---------- */
.zenbar {
  display: none;
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 60;
  align-items: center;
  gap: 10px;
  padding: 5px 8px 5px 6px;
  border: 1px solid var(--glass-br);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
}

.zenbar button {
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.zenbar .zhint {
  font-size: 10px;
  color: var(--text3);
  white-space: nowrap;
}

body.layout-zen .zenbar {
  display: flex;
}

/* ---------- 专注 / 全屏：顶栏与功能区更紧凑 ---------- */
body.layout-focus {
  --h-top: 34px;
  --h-ribbon: 68px;   /* 单行按钮(42) + 组标题(16) + 内边距 + 横向滚动条 */
}

body.layout-focus .topbar {
  height: 34px;
  padding: 0 10px;
  gap: 8px;
}

body.layout-focus .logo {
  font-size: 13px;
}

body.layout-focus .logo svg {
  width: 17px;
  height: 17px;
}

body.layout-focus .rbtn {
  height: 42px;
}

body.layout-focus .rgroup {
  padding: 1px 5px 2px;
}

body.layout-focus .rtitle {
  padding: 0 0 2px;
}

/* 竖排把手在紧凑模式下只留折叠 / 浮动两个按钮，不再撑高功能区 */
body.layout-focus .ribbon {
  height: var(--h-ribbon);
  min-height: 0;
}

body.layout-focus .dockbar-v {
  padding: 1px 0;
  gap: 2px;
}

body.layout-focus .dockbar-v .dbtitle {
  display: none;
}

body.layout-zen .topbar,
body.layout-zen .ribbon {
  display: none;
}

/* ---------- 边缘标签（唤出侧栏） ---------- */
.body {
  position: relative;
}

.edgetab {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  width: 22px;
  padding: 12px 3px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 2px;
  font-size: 11px;
  color: var(--text2);
  border: 1px solid var(--glass-br);
  background: var(--glass-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
}

.edgetab-l {
  left: 0;
  border-radius: 0 9px 9px 0;
  border-left: 0;
}

.edgetab-r {
  right: 0;
  border-radius: 9px 0 0 9px;
  border-right: 0;
}

.edgetab:hover,
.edgetab.active {
  background: var(--accent);
  color: #fff;
}

body.layout-focus .edgetab,
body.layout-zen .edgetab {
  display: block;
}

/* ---------- 覆盖式抽屉：左右面板不再占画布宽度 ---------- */
body.layout-focus .left,
body.layout-focus .right,
body.layout-zen .left,
body.layout-zen .right {
  display: flex;
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 40;
  max-width: 82vw;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  transition: transform .18s ease;
}

body.layout-focus .left,
body.layout-zen .left {
  left: 0;
  border-radius: 0 10px 10px 0;
  transform: translateX(-101%);
}

body.layout-focus .right,
body.layout-zen .right {
  right: 0;
  border-radius: 10px 0 0 10px;
  transform: translateX(101%);
}

body.layout-focus .left.open,
body.layout-focus .right.open,
body.layout-zen .left.open,
body.layout-zen .right.open {
  transform: none;
}

/* 浮动窗口（用户之前拖出来的）保持原位，不受抽屉位移影响 */
body.layout-focus .left.floating,
body.layout-focus .right.floating,
body.layout-focus .bottom.floating,
body.layout-zen .left.floating,
body.layout-zen .right.floating,
body.layout-zen .bottom.floating {
  transform: none;
}

/* ---------- 悬浮命令行 ---------- */
body.layout-focus .bottom,
body.layout-zen .bottom {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  width: min(900px, calc(100% - 24px));
  z-index: 35;
  border: 1px solid var(--glass-br);
  border-radius: 9px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: opacity .15s;
}

body.layout-focus .bottom:not(:hover):not(:focus-within),
body.layout-zen .bottom:not(:hover):not(:focus-within) {
  opacity: .88;
}

/* 标题栏与缩放手柄在悬浮态用不上，收起来换成更干净的命令行 */
body.layout-focus .bottom .logbar,
body.layout-zen .bottom .logbar,
body.layout-focus .bottom .splitter,
body.layout-zen .bottom .splitter {
  display: none;
}

body.layout-focus .bottom #log,
body.layout-zen .bottom #log {
  display: none;
}

body.layout-focus.logopen .bottom #log,
body.layout-zen.logopen .bottom #log {
  display: block;
  height: 116px;
  border-bottom: 1px solid var(--border2);
  background: transparent;
}

body.layout-focus .bottom .cmdrow,
body.layout-zen .bottom .cmdrow {
  border-top: 0;
  padding: 6px 10px;
  background: transparent;
}

body.layout-focus #hint,
body.layout-zen #hint {
  max-width: 32%;
  color: var(--accent);
  font-weight: 600;
}

.cmdmini {
  flex: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--input);
  color: var(--text2);
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.cmdmini:hover {
  background: var(--hover);
  color: var(--text);
}

.cmdmini.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 悬浮状态栏 HUD ---------- */
body.layout-focus .status,
body.layout-zen .status {
  position: fixed;
  left: 12px;
  bottom: 62px;
  width: auto;
  max-width: calc(100vw - 24px);
  height: 24px;
  z-index: 36;
  border: 1px solid var(--glass-br);
  border-radius: 6px;
  background: var(--glass-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  opacity: .94;
  transition: bottom .18s ease;
}

body.layout-focus.logopen .status,
body.layout-zen.logopen .status {
  bottom: 190px;
}

body.layout-focus .status .sp,
body.layout-zen .status .sp {
  flex: 0 0 8px;
}

/* 抽屉展开时不遮挡悬浮状态栏与命令行 */
body.drawer-l.layout-focus .status,
body.drawer-l.layout-zen .status {
  left: calc(var(--w-left) + 16px);
}

body.layout-focus .status,
body.layout-zen .status {
  z-index: 46;
}

body.layout-focus .bottom,
body.layout-zen .bottom {
  z-index: 47;
}

/* ---------- 画布上的短消息（历史折叠时不至于"无声"） ---------- */
.toast {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translate(-50%, -8px);
  z-index: 34;
  max-width: min(720px, calc(100% - 30px));
  padding: 7px 14px;
  border: 1px solid var(--glass-br);
  border-radius: 7px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  white-space: normal;
  word-break: break-all;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.layout-classic .toast,
body.layout-classic .cmdmini {
  display: none;   /* 经典模式命令历史常驻，不需要「历史」按钮与画布短提示 */
}

/* ---------- 窄屏适配 ---------- */
@media (max-width: 820px) {
  body.layout-focus,
  body.layout-zen {
    --h-ribbon: 58px;
  }
  .layoutseg .lseg {
    padding: 4px 7px;
    font-size: 10px;
  }
  .topbar #btnRibbon {
    display: none;
  }
  body.layout-focus .bottom,
  body.layout-zen .bottom {
    width: calc(100% - 16px);
    bottom: 8px;
  }
  body.layout-focus .status,
  body.layout-zen .status {
    bottom: 60px;
    left: 8px;
  }
  body.layout-focus .status .sep,
  body.layout-zen .status .sep {
    display: none;
  }
  .zenbar .zhint {
    display: none;
  }
  .edgetab {
    width: 20px;
    font-size: 10px;
  }
}
