/* ============================================================
   云网页 CloudPage · 工作台样式
   ============================================================ */

/* ================= 布局骨架 ================= */
.app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--statusbar-h);
  height: 100vh;
  overflow: hidden;
}

.body {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr var(--insp-w);
  min-height: 0;
  overflow: hidden;
}

.body.collapsed-rail { grid-template-columns: 0 1fr var(--insp-w); }
.body.collapsed-insp { grid-template-columns: var(--rail-w) 1fr 0; }

/* ================= 顶栏 ================= */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 30;
}

.brand { display: flex; align-items: center; gap: 8px; padding-right: 4px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--o), #ff9a3d);
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(255, 105, 0, .32);
}
.brand-name { font-size: 14px; font-weight: 700; letter-spacing: -.2px; }
.brand-sub { font-size: 10.5px; color: var(--e); font-weight: 500; letter-spacing: .3px; }

.topbar-sep { width: 1px; height: 20px; background: var(--line); }

.doc-title {
  display: flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600;
  transition: background var(--dur) var(--ease);
}
.doc-title:hover { background: var(--b); }
.doc-title input {
  border: none; background: transparent; font-weight: 600; font-size: 13px;
  width: 130px; padding: 0;
}
.doc-title .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.doc-title .dot.dirty { background: var(--yellow); }

.spacer { flex: 1; }

.vp-switch {
  display: flex; align-items: center; gap: 2px;
  padding: 2px; background: var(--b);
  border-radius: var(--r-sm);
}
.vp-switch button {
  height: 24px; padding: 0 9px; border-radius: 4px;
  font-size: 11.5px; font-weight: 500; color: var(--f);
  display: inline-flex; align-items: center; gap: 4px;
  transition: all var(--dur) var(--ease);
}
.vp-switch button:hover { color: var(--h); }
.vp-switch button.on { background: var(--w); color: var(--o); box-shadow: var(--sh-1); }

.zoom-box { display: flex; align-items: center; gap: 4px; }
.zoom-val {
  min-width: 46px; text-align: center; font-size: 11.5px; font-weight: 600;
  color: var(--f); font-variant-numeric: tabular-nums;
}

/* ================= 左侧栏 ================= */
.rail {
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0; overflow: hidden;
}
.collapsed-rail .rail { display: none; }

.rail-tabs {
  display: flex; align-items: center; gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--line);
}
.rail-tab {
  position: relative;
  height: 30px; padding: 0 10px;
  font-size: 12.5px; font-weight: 500; color: var(--f);
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: all var(--dur) var(--ease);
}
.rail-tab:hover { color: var(--h); background: var(--a); }
.rail-tab.on { color: var(--o); font-weight: 600; }
.rail-tab.on::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; background: var(--o); border-radius: 2px 2px 0 0;
}
.rail-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px; min-height: 0; }

.grp-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; color: var(--e);
  letter-spacing: .6px; text-transform: uppercase;
  margin: 4px 2px 8px;
}
.grp-title::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }
.grp + .grp { margin-top: 14px; }

/* 组件库 */
.lib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lib-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  padding: 9px 8px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--w);
  cursor: grab; user-select: none;
  transition: all var(--dur) var(--ease);
}
.lib-item:hover {
  border-color: var(--o); background: #fffaf6;
  transform: translateY(-1px); box-shadow: var(--sh-2);
}
.lib-item:active { cursor: grabbing; }
.lib-item.dragging { opacity: .4; }
.lib-ico {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--b); color: var(--g);
  transition: all var(--dur) var(--ease);
}
.lib-item:hover .lib-ico { background: var(--o); color: #fff; }
.lib-name { font-size: 11.5px; font-weight: 500; color: var(--g); line-height: 1.3; }
.lib-item:hover .lib-name { color: var(--h); }

/* 图层树 */
.tree { display: flex; flex-direction: column; gap: 1px; }
.tree-node {
  display: flex; align-items: center; gap: 5px;
  height: 27px; padding: 0 6px 0 4px;
  border-radius: var(--r-xs);
  font-size: 12px; color: var(--g);
  cursor: pointer; user-select: none;
  transition: all var(--dur) var(--ease);
}
.tree-node:hover { background: var(--b); }
.tree-node.sel { background: var(--o-soft); color: var(--o); font-weight: 600; }
.tree-node.drag-over { box-shadow: inset 0 2px 0 var(--o); }
.tree-node.dragging { opacity: .4; }
.tree-caret {
  width: 14px; height: 14px; flex: none; display: grid; place-items: center;
  color: var(--e); border-radius: 3px;
}
.tree-caret:hover { background: var(--c); color: var(--h); }
.tree-caret.leaf { visibility: hidden; }
.tree-ico { width: 15px; flex: none; display: grid; place-items: center; color: var(--e); }
.tree-node.sel .tree-ico { color: var(--o); }
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-eye { width: 18px; height: 18px; border-radius: 3px; display: grid; place-items: center; color: var(--e); opacity: 0; }
.tree-node:hover .tree-eye { opacity: 1; }
.tree-eye:hover { background: var(--c); color: var(--h); }
.tree-eye.off { opacity: 1; color: var(--d); }
.tree-count { font-size: 10px; color: var(--d); font-variant-numeric: tabular-nums; }

/* ================= 中央画布 ================= */
.stage {
  position: relative;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: transparent;
  overflow: hidden;
}

.stage-bar {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .7);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  flex: none;
}
.breadcrumb { display: flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--e); min-width: 0; }
.breadcrumb span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
.breadcrumb .cur { color: var(--g); font-weight: 600; }

.stage-scroll {
  flex: 1; overflow: auto; min-height: 0;
  padding: 22px 0 60px;
  display: flex; justify-content: center; align-items: flex-start;
}

.canvas-wrap { transform-origin: top center; transition: transform var(--dur) var(--ease); }

.canvas-frame {
  background: #fff;
  box-shadow: 0 10px 40px rgba(24, 24, 27, .1), 0 2px 8px rgba(24, 24, 27, .05);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  transition: width var(--dur) var(--ease);
  /* 空页面时也要保留页面感，否则容器塌陷、空状态提示不可见 */
  min-height: 600px;
}
.canvas-frame.tablet { width: 820px; }
.canvas-frame.mobile { width: 390px; min-height: 720px; }

/* 网格吸附辅助线 */
.snap-guide {
  position: absolute; background: #f43f5e; z-index: 999; pointer-events: none;
  opacity: .85;
}
.snap-guide.v { width: 1px; top: 0; bottom: 0; }
.snap-guide.h { height: 1px; left: 0; right: 0; }

/* 画布内元素 */
.cp-node { position: relative; }
.cp-node.can-drop { outline: 2px dashed var(--o); outline-offset: -2px; }

.cp-node.sel::after {
  content: ''; position: absolute; inset: -1px;
  border: 1.5px solid var(--o);
  border-radius: 2px; pointer-events: none; z-index: 5;
}
.cp-node.sel::before {
  content: ''; position: absolute; inset: -4px;
  border: 1px solid var(--o-soft-2); border-radius: 4px; pointer-events: none; z-index: 4;
}

.cp-node .sel-tag {
  position: absolute; top: -20px; left: -1px;
  height: 17px; padding: 0 6px;
  display: none; align-items: center;
  background: var(--o); color: #fff;
  font-size: 10px; font-weight: 600; border-radius: 3px 3px 0 0;
  white-space: nowrap; z-index: 10; pointer-events: none;
  font-family: var(--mono);
}
.cp-node.sel > .sel-tag { display: flex; }

.cp-node .handle {
  position: absolute; width: 8px; height: 8px;
  background: #fff; border: 1.5px solid var(--o);
  border-radius: 2px; z-index: 11; display: none;
}
.cp-node.sel > .handle { display: block; }
.handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }

.cp-node .node-tools {
  position: absolute; top: -22px; right: 0;
  display: none; gap: 2px; z-index: 12;
  background: var(--w); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 2px; box-shadow: var(--sh-2);
}
.cp-node.sel > .node-tools { display: flex; }
.node-tools button {
  width: 19px; height: 19px; border-radius: 3px;
  display: grid; place-items: center; color: var(--f);
}
.node-tools button:hover { background: var(--b); color: var(--h); }
.node-tools button.danger:hover { background: var(--red-soft); color: var(--red); }

.cp-node.hidden-el { display: none !important; }
.cp-node.locked { pointer-events: none; }
.cp-node.locked > .sel-tag::after { content: ' 🔒'; }

/* 拖拽插入占位 */
.drop-line {
  position: absolute; height: 3px; background: var(--o);
  border-radius: 2px; z-index: 900; pointer-events: none;
  box-shadow: 0 0 0 3px var(--o-soft);
}
.drop-line::before, .drop-line::after {
  content: ''; position: absolute; top: 50%; width: 7px; height: 7px;
  background: var(--o); border-radius: 50%; transform: translateY(-50%);
}
.drop-line::before { left: -4px; }
.drop-line::after { right: -4px; }

.drop-box {
  position: absolute; z-index: 900; pointer-events: none;
  border: 2px dashed var(--o); background: var(--o-soft);
  border-radius: 4px;
}

.canvas-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
}
.canvas-frame.has-content .canvas-empty { display: none; }
.canvas-empty-in { text-align: center; color: var(--e); }
.canvas-empty-in h3 { font-size: 16px; font-weight: 600; color: #52525b; margin-bottom: 8px; }
.canvas-empty-in p { font-size: 12.5px; line-height: 1.9; }
.canvas-empty-in kbd {
  display: inline-block; padding: 1px 5px; margin: 0 1px;
  border: 1px solid var(--c); border-bottom-width: 2px;
  border-radius: 4px; background: var(--w);
  font-size: 11px; font-family: var(--mono); color: var(--f);
}

/* 画布内可编辑文字 */
[contenteditable][data-edit]:focus {
  outline: 2px solid var(--o-soft-2);
  outline-offset: 2px; border-radius: 2px;
}

/* ================= 右侧检查器 ================= */
.inspector {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0; overflow: hidden;
}
.collapsed-insp .inspector { display: none; }

.insp-pane,
.js-pane,
.code-pane {
  display: flex; flex-direction: column;
  height: 100%; min-height: 0; flex: 1;
}
.insp-pane[hidden],
.js-pane[hidden],
.code-pane[hidden] { display: none !important; }

/* ---------- 生成代码面板 ---------- */
.code-tabs {
  display: flex; gap: 2px; padding: 7px 8px 0;
  border-bottom: 1px solid var(--line); flex: none;
}
.code-tab {
  position: relative; height: 28px; padding: 0 10px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--f);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: all var(--dur) var(--ease);
}
.code-tab:hover { background: var(--a); color: var(--h); }
.code-tab.on { color: var(--o); }
.code-tab.on::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; background: var(--o); border-radius: 2px 2px 0 0;
}
.code-view-lg {
  flex: 1; min-height: 0; margin: 8px;
  border-radius: var(--r-md);
  white-space: pre; overflow: auto;
  font-size: 11px; line-height: 1.75;
}

/* ---------- 图层搜索 ---------- */
.tree-search {
  display: flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 9px; margin-bottom: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--e);
  transition: all var(--dur) var(--ease);
}
.tree-search:focus-within { border-color: var(--o); box-shadow: 0 0 0 3px var(--o-soft); color: var(--o); }
.tree-search input {
  flex: 1; border: none; background: transparent; font-size: 12.5px; color: var(--h);
  min-width: 0;
}
.tree-search button {
  width: 17px; height: 17px; border-radius: 3px;
  display: grid; place-items: center; color: var(--e);
}
.tree-search button:hover { background: var(--c); color: var(--h); }
.tree-node mark {
  background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px;
}
.tree-node.dim { opacity: .32; }

/* ---------- 区块模板 ---------- */
.tpl-list { display: flex; flex-direction: column; gap: 7px; }
.tpl-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--w); cursor: grab; user-select: none;
  transition: all var(--dur) var(--ease);
}
.tpl-item:hover {
  border-color: var(--o); background: #fffaf6;
  transform: translateY(-1px); box-shadow: var(--sh-2);
}
.tpl-item:active { cursor: grabbing; }
.tpl-item.dragging { opacity: .4; }
.tpl-ico {
  width: 30px; height: 30px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--o-soft); color: var(--o);
  transition: all var(--dur) var(--ease);
}
.tpl-item:hover .tpl-ico { background: var(--o); color: #fff; }
.tpl-meta { min-width: 0; }
.tpl-name { font-size: 12.5px; font-weight: 600; color: var(--h); margin-bottom: 2px; }
.tpl-desc { font-size: 11px; color: var(--e); line-height: 1.4; }
.tpl-cat {
  margin-left: auto; flex: none;
  font-size: 10px; color: var(--e);
  background: var(--panel-2); border: 1px solid var(--line-2);
  padding: 1px 6px; border-radius: 10px;
}

.insp-head {
  display: flex; align-items: center; gap: 7px;
  height: 42px; padding: 0 12px;
  border-bottom: 1px solid var(--line); flex: none;
}
.insp-ico {
  width: 22px; height: 22px; border-radius: var(--r-sm);
  background: var(--o-soft); color: var(--o);
  display: grid; place-items: center;
}
.insp-title { font-size: 13px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-tabs {
  display: flex; gap: 2px; padding: 6px 8px 0;
  border-bottom: 1px solid var(--line); flex: none;
}
.insp-tab {
  position: relative; height: 28px; padding: 0 9px;
  font-size: 12px; font-weight: 500; color: var(--f);
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: all var(--dur) var(--ease);
}
.insp-tab:hover { color: var(--h); background: var(--a); }
.insp-tab.on { color: var(--o); font-weight: 600; }
.insp-tab.on::after {
  content: ''; position: absolute; left: 6px; right: 6px; bottom: -1px;
  height: 2px; background: var(--o); border-radius: 2px 2px 0 0;
}
.insp-scroll { flex: 1; overflow-y: auto; padding: 10px 12px 24px; min-height: 0; }

.fld { margin-bottom: 9px; }
.fld-label {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--f);
  margin-bottom: 4px;
}
.fld-label .u { font-weight: 400; color: var(--d); }
.fld-row { display: flex; align-items: center; gap: 6px; }
.fld-row > * { min-width: 0; }

.ctl-color {
  position: relative; width: 28px; height: 28px; flex: none;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  overflow: hidden; cursor: pointer;
}
.ctl-color input { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); border: none; padding: 0; cursor: pointer; }
.ctl-color .none-mark {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(to bottom right, transparent 45%, #ef4444 45%, #ef4444 55%, transparent 55%);
  display: none;
}
.ctl-color.is-none .none-mark { display: block; }

.ctl-slider { display: flex; align-items: center; gap: 7px; }
.ctl-slider input[type=range] {
  flex: 1; height: 3px; -webkit-appearance: none; appearance: none;
  background: var(--c); border-radius: 2px; cursor: pointer;
}
.ctl-slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px;
  background: var(--w); border: 1.5px solid var(--o); border-radius: 50%;
  box-shadow: var(--sh-1); cursor: grab;
}
.ctl-slider .val {
  min-width: 38px; height: 24px; padding: 0 5px;
  border: 1px solid var(--line); border-radius: var(--r-xs);
  font-size: 11px; text-align: center; font-variant-numeric: tabular-nums;
}

.seg {
  display: flex; padding: 2px; gap: 2px;
  background: var(--b); border-radius: var(--r-sm);
}
.seg button {
  flex: 1; height: 23px; border-radius: 4px;
  display: grid; place-items: center; color: var(--f);
  transition: all var(--dur) var(--ease);
}
.seg button:hover { color: var(--h); }
.seg button.on { background: var(--w); color: var(--o); box-shadow: var(--sh-1); }

.preset-row { display: flex; flex-wrap: wrap; gap: 5px; }
.preset {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  border: 1px solid var(--line); cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.preset:hover { transform: scale(1.08); border-color: var(--h); }

/* 尺寸四联动 */
.dim4 { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.dim4 .fld { margin: 0; }
.dim4-t {
  grid-column: 1 / -1; font-size: 10.5px; font-weight: 600; color: var(--e);
  display: flex; align-items: center; gap: 5px; margin-top: 3px;
}

.pane-head {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 12px; background: #fff;
  border-bottom: 1px solid var(--line); flex: none;
}
.pane-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 9px; background: var(--b); border-radius: var(--r-sm);
  font-size: 12px; font-weight: 600; max-width: 190px;
}
.pane-chip .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-chip .tagid { font-family: var(--mono); font-size: 10px; color: var(--o); background: #fff; padding: 1px 4px; border-radius: 3px; }
#js-el { max-width: 118px; }

/* ================= 交互代码编辑器 ================= */
.js-scope {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; background: #fff;
  border-bottom: 1px solid var(--line); flex: none;
}
.js-seg { display: inline-flex; background: var(--b); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.js-seg button {
  height: 23px; padding: 0 9px; border-radius: 5px;
  font-size: 11px; font-weight: 600; color: var(--f);
  transition: all var(--dur) var(--ease);
}
.js-seg button:hover { color: var(--h); }
.js-seg button.on { background: #fff; color: var(--o); box-shadow: var(--sh-1); }
.js-id {
  margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--e);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 128px;
}

.js-editorwrap { flex: 1; min-height: 0; display: flex; overflow: hidden; background: var(--panel-2); }
.js-gutter {
  flex: none; width: 36px; padding: 10px 0; overflow: hidden;
  text-align: right; background: #f6f6f8; border-right: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 11px; line-height: 1.65;
  color: var(--d); user-select: none;
}
.js-gutter .jn { padding: 0 7px 0 0; }
.js-gutter .jn.on { color: var(--o); background: rgba(255, 105, 0, .07); }

.js-code { flex: 1; min-width: 0; overflow: auto; display: grid; }
.js-hl, .js-in {
  grid-area: 1 / 1;
  margin: 0; border: 0; padding: 10px 12px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
  tab-size: 2; -moz-tab-size: 2;
  background: transparent;
}
.js-hl { pointer-events: none; color: var(--h); }
.js-code.nowrap .js-hl,
.js-code.nowrap .js-in { white-space: pre; overflow-wrap: normal; }
.js-in {
  resize: none; outline: none; overflow: hidden;
  color: transparent; caret-color: var(--h);
  -webkit-text-fill-color: transparent;
}
.js-in::selection { background: rgba(255, 105, 0, .22); }
/* 高亮渲染失败时的降级：让 textarea 的文字重新显形 */
.js-code.no-hl .js-in { color: var(--h); -webkit-text-fill-color: currentColor; }

/* 语法着色 —— 只允许改颜色。
   任何字重 / 字号 / 字距差异都会让输入层与着色层换行错位。 */
.js-hl .t-kw { color: #a626a4; }
.js-hl .t-str { color: #3f9142; }
.js-hl .t-num { color: #b76b01; }
.js-hl .t-cm { color: #a8a8b0; }
.js-hl .t-fn { color: #3b6ef0; }
.js-hl .t-el { color: #c18401; }
.js-hl .t-pn { color: #5b6472; }

.js-status {
  flex: none; display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-top: 1px solid var(--line-2);
  font-size: 11px; background: #fff; min-height: 33px;
}
.js-status .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--c); }
.js-status .js-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.js-status .js-count { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--d); flex: none; }
.js-status.idle { color: var(--e); }
.js-status.ok { color: var(--green); }
.js-status.ok .dot { background: var(--green); }
.js-status.err { color: var(--red); }
.js-status.err .dot { background: var(--red); }
.js-status code {
  font-family: var(--mono); font-size: 10.5px;
  background: var(--a); padding: 1px 4px; border-radius: 3px; color: var(--f);
}

.js-snips {
  flex: none; display: flex; flex-direction: column;
  border-top: 1px solid var(--line-2); background: #fff;
  max-height: 46%; min-height: 0;
}
.js-snips-head {
  display: flex; align-items: center; gap: 6px; flex: none;
  padding: 9px 12px; font-size: 11.5px; font-weight: 600;
  color: var(--f); cursor: pointer;
  transition: color var(--dur) var(--ease);
}
.js-snips-head:hover { color: var(--o); }
.js-snips-head .caret {
  margin-left: auto; width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform var(--dur) var(--ease);
}
.js-snips-head.open .caret { transform: rotate(180deg); }
.js-snips-body { overflow-y: auto; padding: 0 12px 12px; min-height: 0; }
.snip-group + .snip-group { margin-top: 11px; }
.snip-title {
  font-size: 10.5px; font-weight: 700; color: var(--d);
  letter-spacing: .04em; margin-bottom: 6px;
}
.snip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.snip-row button {
  height: 25px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font-size: 11px; font-weight: 500; color: var(--f);
  transition: all var(--dur) var(--ease);
}
.snip-row button:hover { border-color: var(--o); color: var(--o); background: var(--o-soft); }

/* 属性面板里的交互代码入口 */
.code-entry {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 11px; cursor: pointer;
  border: 1px dashed var(--line); border-radius: var(--r-md);
  background: var(--panel-2);
  transition: all var(--dur) var(--ease);
}
.code-entry:hover { border-color: var(--o); background: var(--o-soft); }
.code-entry .ce-ico { display: grid; place-items: center; color: var(--e); flex: none; }
.code-entry.has .ce-ico { color: var(--o); }
.code-entry .ce-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.code-entry .ce-txt b { font-size: 12px; font-weight: 600; color: var(--h); }
.code-entry .ce-txt i { font-style: normal; font-size: 10.5px; color: var(--d); }
.code-entry .ce-go { margin-left: auto; color: var(--c); transform: rotate(90deg); flex: none; }
.code-entry:hover .ce-go { color: var(--o); }

/* ================= JS 库面板 ================= */
.lib-list { display: flex; flex-direction: column; gap: 6px; }
.lib-card {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 9px 10px; background: var(--w);
  transition: all var(--dur) var(--ease);
}
.lib-card:hover { border-color: #d4d4d8; box-shadow: var(--sh-1); }
.lib-card-hd { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.lib-logo {
  width: 22px; height: 22px; border-radius: 5px; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 800;
}
.lib-name { font-size: 12.5px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-ver { font-size: 10px; color: var(--e); font-family: var(--mono); }
.lib-url {
  font-family: var(--mono); font-size: 10.5px; color: var(--f);
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--r-xs); padding: 4px 6px;
  word-break: break-all; line-height: 1.5;
}
.lib-card-ft { display: flex; align-items: center; gap: 6px; margin-top: 7px; }

.lib-add-box {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px; background: var(--panel-2);
}
.lib-add-box .fld { margin-bottom: 7px; }
.lib-quick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.lib-quick button {
  height: 22px; padding: 0 8px; border-radius: 11px;
  background: var(--w); border: 1px solid var(--line);
  font-size: 11px; color: var(--f);
  transition: all var(--dur) var(--ease);
}
.lib-quick button:hover { border-color: var(--o); color: var(--o); background: #fffaf6; }

/* ================= 顶栏下拉菜单 ================= */
.menu-wrap { position: relative; }

.menu-pop {
  position: absolute; top: calc(100% + 7px); right: 0;
  min-width: 214px; z-index: 120;
  background: var(--w);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: 0 14px 44px rgba(24, 24, 27, .16), 0 2px 8px rgba(24, 24, 27, .07);
  padding: 5px;
  animation: popIn .14s var(--ease);
}
.menu-pop[hidden] { display: none; }
.menu-pop button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; height: 32px; padding: 0 9px;
  border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--g); text-align: left;
  transition: all var(--dur) var(--ease);
}
.menu-pop button:hover { background: var(--o-soft); color: var(--o); }
.menu-pop button svg { color: var(--e); flex: none; }
.menu-pop button:hover svg { color: var(--o); }
.menu-pop button span { flex: 1; }
.menu-pop button em {
  font-style: normal; font-size: 10.5px; color: var(--d);
  font-family: var(--mono);
}
.menu-div { height: 1px; background: var(--line-2); margin: 5px 4px; }

/* ================= 右键菜单 ================= */
.ctx-menu {
  position: fixed; z-index: 250;
  min-width: 192px;
  background: var(--w);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: 0 14px 44px rgba(24, 24, 27, .18), 0 2px 8px rgba(24, 24, 27, .07);
  padding: 5px;
  animation: popIn .12s var(--ease);
}
.ctx-menu[hidden] { display: none; }
.ctx-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; height: 30px; padding: 0 9px;
  border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--g); text-align: left;
  transition: all var(--dur) var(--ease);
}
.ctx-item:hover { background: var(--b); color: var(--h); }
.ctx-item svg { color: var(--e); flex: none; }
.ctx-item span { flex: 1; }
.ctx-item em { font-style: normal; font-size: 10.5px; color: var(--d); font-family: var(--mono); }
.ctx-item.danger:hover { background: var(--red-soft); color: var(--red); }
.ctx-item.danger:hover svg { color: var(--red); }
.ctx-item[disabled] { opacity: .4; pointer-events: none; }
.ctx-div { height: 1px; background: var(--line-2); margin: 5px 4px; }

/* ================= 小提示 ================= */
.rail-tip {
  margin-top: 14px; padding: 11px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  font-size: 11.5px; line-height: 1.95; color: var(--e);
}
.rail-tip b { color: var(--f); font-weight: 600; }

.stage-hint { font-size: 11px; color: var(--e); }

/* ================= 状态栏 ================= */
.statusbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--e);
}
.statusbar .s { display: inline-flex; align-items: center; gap: 4px; }
.statusbar .s b { color: var(--f); font-weight: 600; font-variant-numeric: tabular-nums; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.status-dot.warn { background: var(--yellow); }

/* ================= 弹层 ================= */
.mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(24, 24, 27, .34);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center;
  animation: fadeIn .16s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }

.modal {
  width: min(880px, 92vw); max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--w); border-radius: var(--r-lg);
  box-shadow: 0 24px 70px rgba(24, 24, 27, .26);
  overflow: hidden; animation: popIn .2s var(--ease);
}
.modal-sm { width: min(480px, 92vw); }
.modal-hd {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); flex: none;
}
.modal-hd h3 { font-size: 14.5px; font-weight: 700; flex: 1; }
.modal-hd p { font-size: 11.5px; color: var(--e); font-weight: 400; margin-top: 2px; }
.modal-bd { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.modal-ft {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--line); flex: none;
}
.modal-ft .left { margin-right: auto; }

/* 快捷键表 */
.kbd-list { display: flex; flex-direction: column; gap: 2px; }
.kbd-row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 9px; border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--g);
}
.kbd-row:nth-child(odd) { background: var(--panel-2); }
.kbd-row kbd {
  min-width: 122px; text-align: center;
  padding: 3px 8px; border-radius: 5px;
  border: 1px solid var(--c); border-bottom-width: 2px;
  background: var(--w); color: var(--f);
  font-family: var(--mono); font-size: 11px;
  white-space: nowrap;
}
.kbd-row span { color: var(--f); }

/* 导出预览 */
.exp-grid { display: grid; grid-template-columns: 150px 1fr; gap: 14px; height: 100%; }
.exp-files { border-right: 1px solid var(--line); padding-right: 12px; }
.exp-file {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: var(--r-sm);
  font-size: 12px; color: var(--g); cursor: pointer; width: 100%; text-align: left;
}
.exp-file:hover { background: var(--b); }
.exp-file.on { background: var(--o-soft); color: var(--o); font-weight: 600; }
.exp-file .sz { margin-left: auto; font-size: 10px; color: var(--d); font-variant-numeric: tabular-nums; }
.code-view {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.72;
  background: #1c1c1f; color: #e4e4e7;
  border-radius: var(--r-md); padding: 13px 15px;
  overflow: auto; max-height: 52vh; white-space: pre; tab-size: 2;
}
.code-view .c { color: #6b7280; }
.code-view .t { color: #7dd3fc; }
.code-view .a { color: #fdba74; }
.code-view .s { color: #86efac; }

/* Toast */
.toast-wrap {
  position: fixed; top: 62px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 7px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 20px;
  background: var(--h); color: #fff; font-size: 12.5px; font-weight: 500;
  box-shadow: var(--sh-3);
  animation: toastIn .22s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }
.toast .ic { color: #4ade80; }
.toast.err .ic { color: #f87171; }

/* 引导高亮 */
.spot {
  position: fixed; z-index: 190; pointer-events: none;
  border: 2px solid var(--o); border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(24, 24, 27, .55);
  transition: all .3s var(--ease);
}
.spot-txt {
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: var(--w); border-radius: var(--r-md); padding: 11px 14px;
  box-shadow: var(--sh-3); width: 300px; z-index: 191;
}
.spot-txt h4 { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.spot-txt p { font-size: 12px; color: var(--f); line-height: 1.7; }
.spot-nav { display: flex; align-items: center; gap: 7px; margin-top: 10px; }
.spot-nav .n { font-size: 11px; color: var(--e); margin-right: auto; }

.seg button.hide-on { background: #fff; color: var(--red); box-shadow: var(--sh-1); }
.cp-node.vp-hidden { display: none !important; }

/* 代码面板的工具按钮状态 */
#js-live.primary { background: var(--green-soft); border-color: rgba(22, 163, 74, .3); color: var(--green); }
#js-wrap.primary { background: var(--o-soft); border-color: rgba(255, 105, 0, .28); color: var(--o); }

/* ================= AI 生成抽屉 ================= */
.ai-drawer {
  position: fixed; top: var(--topbar-h); right: 0; bottom: var(--statusbar-h);
  width: 460px; max-width: 96vw; z-index: 160;
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -14px 0 40px rgba(24, 24, 27, .1);
  transform: translateX(100%);
  transition: transform .22s var(--ease);
}
.ai-drawer[hidden] { display: none !important; }
.ai-drawer.on { transform: none; }

.ai-head {
  flex: none; display: flex; align-items: center; gap: 6px;
  padding: 9px 12px; border-bottom: 1px solid var(--line);
}
.ai-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ai-spark {
  width: 25px; height: 25px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 12px; color: #fff;
  background: linear-gradient(135deg, #ff9040, var(--o));
}
.ai-brand-txt { display: flex; flex-direction: column; min-width: 0; }
.ai-brand-txt b { font-size: 12.5px; font-weight: 700; color: var(--h); }
.ai-brand-txt i {
  font-style: normal; font-size: 10.5px; color: var(--e);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px;
}
.ai-brand-txt i.warn { color: var(--red); }

.ai-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ai-view[hidden] { display: none !important; }

.ai-modes { flex: none; display: flex; gap: 3px; padding: 8px 12px 0; background: #fff; }
.ai-modes button {
  height: 28px; padding: 0 12px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  font-size: 12px; font-weight: 600; color: var(--f);
  border-bottom: 2px solid transparent;
  transition: all var(--dur) var(--ease);
}
.ai-modes button:hover { color: var(--h); background: var(--a); }
.ai-modes button.on { color: var(--o); border-bottom-color: var(--o); }

/* 对话区容器：相对定位，给「回到最新」按钮留锚点 */
.ai-log-wrap {
  position: relative;
  flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.ai-log {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--panel-2); border-top: 1px solid var(--line-2);
  /* 滚到边界时不要把滚动继续传给外层 */
  overscroll-behavior: contain;
}

/* 回到最新：往上翻看历史时浮在对话区底部 */
.ai-jump {
  position: absolute; left: 50%; bottom: 14px; z-index: 6;
  display: flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 13px 0 10px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
  box-shadow: 0 5px 18px rgba(24, 24, 27, .16);
  font-size: 11.5px; font-weight: 600; color: var(--h);
  opacity: 0; transform: translateX(-50%) translateY(8px);
  transition: opacity .16s var(--ease), transform .16s var(--ease),
              color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.ai-jump svg { flex: none; }
.ai-jump.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.ai-jump:hover:not(:disabled) { color: var(--o); border-color: var(--o); }
.ai-jump:disabled { pointer-events: none; }
.ai-welcome { font-size: 12px; color: var(--f); line-height: 1.9; }
.ai-welcome-title { font-weight: 700; color: var(--h); margin-bottom: 3px; }
.ai-welcome ul { margin: 0; padding-left: 16px; }
.ai-welcome li { list-style: disc; }

.ai-msg { display: flex; flex-direction: column; gap: 8px; }
.ai-msg.user { align-items: flex-end; }
.ai-bubble {
  max-width: 88%; padding: 9px 12px;
  border-radius: 12px 12px 4px 12px;
  background: var(--o); color: #fff;
  font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.ai-stream,
.ai-think {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-md); overflow: hidden;
}
.ai-stream pre {
  margin: 0; padding: 10px; max-height: 240px; overflow: auto;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.65;
  color: var(--g); white-space: pre-wrap; word-break: break-all;
}
.ai-stream pre::-webkit-scrollbar { width: 6px; }
.ai-stream.collapsed pre { max-height: 84px; }

/* ---------- 步骤时间线：把「正在做什么」摊开 ---------- */
.ai-steps {
  margin: 0; padding: 9px 10px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  display: flex; flex-direction: column; gap: 6px;
}
.ai-steps li {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; line-height: 1.5; color: var(--e);
  transition: color var(--dur) var(--ease);
}
.ai-steps li .ai-step-txt { flex: 1; min-width: 0; }
.ai-steps li em {
  font-style: normal; font-family: var(--mono); font-size: 10px;
  color: var(--e); flex: none;
}
.ai-step-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--c);
  transition: all var(--dur) var(--ease);
}
.ai-steps li.active { color: var(--h); }
.ai-steps li.active .ai-step-dot { background: var(--o); box-shadow: 0 0 0 3px var(--o-soft); }
.ai-steps li.active em { color: var(--o); }
.ai-steps li.done { color: var(--f); }
.ai-steps li.done .ai-step-dot { background: var(--green); }
.ai-steps li.done em { color: var(--e); }
.ai-steps li.fail { color: var(--red); }
.ai-steps li.fail .ai-step-dot { background: var(--red); }
.ai-steps li.skip { color: var(--d); }
.ai-steps li.skip .ai-step-dot { background: var(--d); }

/* ---------- 思考过程 ---------- */
.ai-sec-hd {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; background: var(--a);
  border-bottom: 1px solid var(--line-2);
  font-size: 11.5px; color: var(--f);
}
.ai-sec-ico {
  font-family: var(--mono); font-size: 10px; color: var(--o);
  min-width: 15px; text-align: center; flex: none;
}
.ai-sec-title { font-weight: 700; color: var(--h); font-size: 11.5px; }
.ai-sec-tag {
  font-size: 9.5px; padding: 1px 5px; border-radius: 4px;
  background: var(--purple-soft); color: var(--purple);
}
.ai-sec-tag.reason { background: var(--cyan-soft); color: var(--cyan); }
.ai-sec-meta { font-family: var(--mono); font-size: 10px; color: var(--e); }
.ai-sec-toggle {
  height: 20px; padding: 0 7px; border-radius: 5px;
  font-size: 10.5px; color: var(--f); background: #fff;
  border: 1px solid var(--line);
}
.ai-sec-toggle:hover { border-color: var(--o); color: var(--o); }

.ai-think-body {
  padding: 10px 11px; max-height: 260px; overflow-y: auto;
  font-size: 12px; line-height: 1.85; color: var(--g);
  white-space: pre-wrap; word-break: break-word;
}
.ai-think.collapsed .ai-think-body { max-height: 72px; overflow: hidden; }
.ai-think-sep {
  display: flex; align-items: center; gap: 8px;
  margin: 9px 0 6px; font-size: 10.5px; color: var(--e);
}
.ai-think-sep::before, .ai-think-sep::after {
  content: ''; flex: 1; height: 1px; background: var(--line-2);
}

.ai-card { border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; overflow: hidden; }
.ai-card-hd {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 9px 11px; font-size: 12px; font-weight: 600; color: var(--h);
  background: var(--green-soft); border-bottom: 1px solid rgba(22, 163, 74, .18);
}
.ai-ok { color: var(--green); font-weight: 800; }

/* 结构化预览 */
.ai-tree { padding: 8px 4px; max-height: 220px; overflow: auto; border-bottom: 1px solid var(--line-2); }
.ai-tree-row {
  display: flex; align-items: baseline; gap: 6px;
  padding: 2px 10px; font-size: 11px; line-height: 1.6;
}
.ai-tree-row:hover { background: var(--a); }
.ai-tree-comp {
  font-family: var(--mono); font-size: 10px; color: var(--o);
  background: var(--o-soft); padding: 0 4px; border-radius: 3px; flex: none;
}
.ai-tree-name { color: var(--h); font-weight: 500; }
.ai-tree-txt {
  color: var(--e); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; min-width: 0;
}
.ai-tree-more { padding: 4px 10px; font-size: 10.5px; color: var(--e); }

.ai-card-ft {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 9px 11px; border-top: 1px solid var(--line-2); background: var(--a);
}
.ai-card-ft .cp-btn { height: 28px; font-size: 11.5px; }
.ai-raw {
  margin: 0; padding: 10px; max-height: 260px; overflow: auto;
  border-top: 1px solid var(--line-2); background: #fbfbfc;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.6; color: var(--g);
}
.ai-codeview {
  margin: 0; padding: 10px 11px; max-height: 220px; overflow: auto;
  font-family: var(--mono); font-size: 11px; line-height: 1.65; color: var(--h);
  white-space: pre-wrap; word-break: break-word;
}
.ai-error {
  padding: 10px 12px; border-radius: var(--r-md);
  font-size: 12px; line-height: 1.75; word-break: break-word;
  background: var(--red-soft); color: #991b1b; border: 1px solid rgba(220, 38, 38, .22);
}

.ai-input-wrap { flex: none; padding: 10px 12px 12px; background: #fff; border-top: 1px solid var(--line); }
.ai-input-wrap textarea {
  width: 100%; min-height: 62px; max-height: 170px; resize: vertical;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-md);
  font-family: var(--font); font-size: 12.5px; line-height: 1.7; color: var(--h);
  outline: none; transition: all var(--dur) var(--ease);
}
.ai-input-wrap textarea:focus { border-color: var(--o); box-shadow: 0 0 0 3px var(--o-soft); }
.ai-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ai-chip {
  height: 24px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff;
  font-size: 11px; color: var(--f);
  transition: all var(--dur) var(--ease);
}
.ai-chip:hover { border-color: var(--o); color: var(--o); background: var(--o-soft); }
.ai-input-ft { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.ai-tip { font-size: 10.5px; color: var(--d); }
.ai-input-ft .cp-btn { height: 30px; }
.ai-input-ft .cp-btn.primary { margin-left: auto; }

/* AI 配置视图 */
.ai-cfg-head {
  flex: none; display: flex; align-items: center; gap: 6px;
  padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.ai-cfg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px; }
.ai-field { margin-bottom: 13px; }
.ai-field label {
  display: block; margin-bottom: 5px;
  font-size: 11px; font-weight: 600; color: var(--f);
}
.ai-temp-val { color: var(--o); font-family: var(--mono); }
.ai-field input {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 12px; color: var(--h);
  outline: none; transition: all var(--dur) var(--ease);
}
.ai-field input:focus { border-color: var(--o); box-shadow: 0 0 0 3px var(--o-soft); }
.ai-field input[type="range"] {
  height: auto; padding: 0; border: 0; box-shadow: none; accent-color: var(--o);
}
.ai-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-preset {
  height: 26px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff;
  font-size: 11px; color: var(--f);
  transition: all var(--dur) var(--ease);
}
.ai-preset:hover { border-color: var(--o); color: var(--o); background: var(--o-soft); }
.ai-cfg-result {
  margin-bottom: 12px; padding: 9px 11px; border-radius: var(--r-sm);
  font-size: 11.5px; line-height: 1.7; word-break: break-word;
}
.ai-cfg-result.ok { background: var(--green-soft); color: #14532d; border: 1px solid rgba(22, 163, 74, .22); }
.ai-cfg-result.err { background: var(--red-soft); color: #991b1b; border: 1px solid rgba(220, 38, 38, .22); }
.ai-note {
  margin-bottom: 14px; padding: 10px 11px;
  font-size: 11px; line-height: 1.85; color: var(--f);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
}
.ai-note b { color: var(--h); }
.ai-cfg-ft { display: flex; gap: 8px; }
.ai-cfg-ft .cp-btn { flex: 1; height: 34px; justify-content: center; }

/* 顶栏 AI 入口：常态深色，打开时转为品牌橙 */
.cp-btn.ai {
  background: var(--h); color: #fff; border-color: var(--h);
  font-weight: 600;
}
.cp-btn.ai:hover { background: #2c2c31; border-color: #2c2c31; color: #fff; }
.cp-btn.ai.primary {
  background: linear-gradient(135deg, #ff9040, var(--o));
  border-color: transparent; color: #fff;
}

/* 设置项里的勾选框 */
.ai-check {
  display: flex; align-items: flex-start; gap: 8px; margin: 0;
  font-size: 11.5px; font-weight: 500; color: var(--f); line-height: 1.65;
  cursor: pointer;
}
.ai-field input[type="checkbox"] {
  width: 15px; height: 15px; margin: 2px 0 0; padding: 0;
  flex: none; accent-color: var(--o); cursor: pointer;
}

/* ================= AI 抽屉：会话列表 + 全屏 ================= */
.ai-body { flex: 1; min-height: 0; display: flex; }
.ai-work { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.ai-side {
  width: 190px; flex: none;
  display: flex; flex-direction: column;
  background: #fff; border-right: 1px solid var(--line);
}
.ai-new {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 10px; height: 32px; flex: none;
  border-radius: var(--r-sm);
  background: var(--h); color: #fff;
  font-size: 12px; font-weight: 600;
  transition: background var(--dur) var(--ease);
}
.ai-new:hover { background: #2c2c31; }

.ai-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; }
.ai-item {
  position: relative; display: flex; align-items: center; gap: 7px;
  padding: 8px 9px; border-radius: var(--r-sm); cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.ai-item:hover { background: var(--a); }
.ai-item.on { background: var(--o-soft); }
.ai-item-ico { font-family: var(--mono); font-size: 10px; color: var(--e); flex: none; }
.ai-item.on .ai-item-ico { color: var(--o); }
.ai-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ai-item-main b {
  font-size: 11.5px; font-weight: 600; color: var(--h);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-item-main i {
  font-style: normal; font-size: 10px; color: var(--e);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-item-del {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 5px;
  display: grid; place-items: center; opacity: 0;
  font-size: 13px; line-height: 1; color: var(--f);
  background: #fff; border: 1px solid var(--line);
  transition: opacity var(--dur) var(--ease);
}
.ai-item:hover .ai-item-del { opacity: 1; }
.ai-item-del:hover { color: var(--red); border-color: rgba(220, 38, 38, .4); }
.ai-side-clear {
  flex: none; margin: 8px 10px 10px; height: 28px;
  border-radius: var(--r-sm);
  font-size: 11px; color: var(--e); background: var(--a);
  border: 1px solid var(--line-2);
  transition: all var(--dur) var(--ease);
}
.ai-side-clear:hover { color: var(--red); border-color: rgba(220, 38, 38, .35); background: var(--red-soft); }

/* 全屏：占满顶栏与状态栏之间的整块区域 */
.ai-drawer { width: 640px; }
.ai-drawer.full {
  left: 0; right: 0; width: auto; max-width: none;
  border-left: 0;
}
.ai-drawer.full .ai-side { width: 224px; }
.ai-drawer.full .ai-log { padding: 18px 22px; }
.ai-drawer.full .ai-bubble { max-width: 62%; }
.ai-drawer.full .ai-think-body { max-height: 46vh; }
.ai-drawer.full .ai-stream pre { max-height: 46vh; }
.ai-drawer.full .ai-tree { max-height: 40vh; }

/* 结果卡：交互与资源的标记 */
.ai-card-extra { font-weight: 500; font-size: 11px; color: #14532d; opacity: .86; }
.ai-tree-js { color: var(--o); font-size: 10px; flex: none; }

/* ================= AI 右侧任务清单（仅全屏显示） ================= */
.ai-todo {
  width: 272px; flex: none;
  display: none; flex-direction: column;
  background: #fff; border-left: 1px solid var(--line);
}
.ai-drawer.full .ai-todo { display: flex; }

.ai-todo-hd {
  flex: none; display: flex; align-items: center; gap: 7px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.ai-todo-ico {
  width: 21px; height: 21px; flex: none; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--o-soft); color: var(--o);
}
.ai-todo-hd b { font-size: 12.5px; font-weight: 700; color: var(--h); }
.ai-todo-hd i {
  font-style: normal; margin-left: auto; font-size: 10.5px; color: var(--e);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px;
}

.ai-todo-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }
.ai-todo-body[hidden] { display: none !important; }
/* 侧栏里步骤列表去掉卡片外壳，做成带连接线的清单 */
.ai-todo-body .ai-steps {
  margin: 0; padding: 0; border: 0; background: transparent;
  border-radius: 0; gap: 12px;
}
.ai-todo-body .ai-steps li {
  position: relative; padding-left: 17px;
  align-items: flex-start; font-size: 12px; line-height: 1.6;
}
.ai-todo-body .ai-step-dot { position: absolute; left: 0; top: 5px; }
.ai-todo-body .ai-steps li::before {
  content: ''; position: absolute; left: 3px; top: 15px; bottom: -12px;
  width: 1px; background: var(--line);
}
.ai-todo-body .ai-steps li:last-child::before { display: none; }
.ai-todo-body .ai-steps li em { font-size: 10.5px; padding-top: 1px; }
.ai-todo-body .ai-steps li.active .ai-step-dot { box-shadow: 0 0 0 4px var(--o-soft); }

.ai-todo-empty {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 20px 18px; text-align: center; color: var(--e);
}
.ai-todo-empty[hidden] { display: none !important; }
.ai-todo-empty b { display: block; font-size: 12px; color: var(--f); margin-bottom: 7px; }
.ai-todo-empty p { margin: 0; font-size: 11px; line-height: 1.9; }

.ai-todo-ft {
  flex: none; padding: 9px 12px; border-top: 1px solid var(--line-2);
  font-size: 10.5px; line-height: 1.75; color: var(--d); background: var(--a);
}

/* 结果卡：被截断时的提示条 */
.ai-partial {
  padding: 9px 12px; font-size: 11.5px; line-height: 1.8;
  color: #713f12; background: var(--yellow-soft);
  border-bottom: 1px solid rgba(202, 138, 4, .25);
}
.ai-partial b { font-weight: 700; }

/* 展示名称：用户自己起的中文名，用正文字体比等宽体好看 */
#ai-displayName { font-family: var(--font); }
.ai-field-tip {
  margin-top: 5px; font-size: 10.5px; line-height: 1.7; color: var(--e);
}
