/* =========================================================
   酷界工具箱 · 网页后台样式（桌面端）
   ---------------------------------------------------------
   与 H5 端共用 builder.js 的渲染类名（.cn-* / .prop-* / .ui-* / .tpl-*），
   这里补齐桌面端布局与这些类的完整样式。
   ========================================================= */

:root {
  --red: #FA3C3C;
  --red-dark: #E02B2B;
  --red-soft: #FFECEC;
  --red-glow: rgba(250, 60, 60, .28);
  --text: #1C1C1E;
  --text-2: #6B6B70;
  --text-3: #A0A0A6;
  --line: #F0F0F2;
  --line-2: #E4E4EA;
  --bg: #F7F7F9;
  --card: #FFFFFF;
  --radius-l: 18px;
  --radius-m: 14px;
  --radius-s: 10px;
  --shadow-s: 0 2px 10px rgba(20, 20, 30, .05);
  --shadow-m: 0 8px 24px rgba(20, 20, 30, .08);
  --shadow-red: 0 8px 22px var(--red-glow);
  --topbar-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}
input, textarea, select, button { font-family: inherit; }
a { color: var(--red); }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px; border: none; border-radius: var(--radius-s);
  font-size: 14px; font-weight: 700; cursor: pointer; transition: .16s;
  white-space: nowrap; background: var(--bg); color: var(--text);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--red); color: #fff; box-shadow: var(--shadow-red); }
.btn.primary:hover { background: var(--red-dark); }
.btn.ghost { background: var(--card); color: var(--text-2); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--red); color: var(--red); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.text { background: transparent; color: var(--text-2); padding: 0 8px; }
.btn.text:hover { color: var(--red); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(135deg, #FFF3F3 0%, #F7F7F9 55%, #EEF2FF 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-mask.hide { display: none; }
.login-card {
  width: 100%; max-width: 400px; background: var(--card);
  border-radius: var(--radius-l); padding: 30px 28px 26px;
  box-shadow: 0 20px 60px rgba(20, 20, 30, .12);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-brand img {
  width: 52px; height: 52px; border-radius: 16px; object-fit: cover;
  box-shadow: var(--shadow-red); flex-shrink: 0;
}
.login-brand h1 { font-size: 18px; font-weight: 800; letter-spacing: -.3px; }
.login-brand p { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.login-field { margin-bottom: 16px; }
.login-field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px;
}
.login-field input {
  width: 100%; height: 44px; border: 1.5px solid var(--line); border-radius: var(--radius-s);
  background: var(--bg); color: var(--text); padding: 0 13px; font-size: 14px; outline: none;
  transition: .16s;
}
.login-field input:focus { border-color: var(--red); background: #fff; }
.login-card .btn.primary { width: 100%; height: 46px; font-size: 15px; margin-top: 6px; }
.login-tip { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 14px; line-height: 1.6; }
.login-tip.err { color: var(--red); }

/* ---------- 顶栏 ---------- */
.admin { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex-shrink: 0; background: var(--card);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 18px; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-logo { width: 28px; height: 28px; border-radius: 9px; object-fit: cover; }
.topbar-title { font-size: 15px; font-weight: 800; letter-spacing: -.2px; }
.topbar-tag {
  font-size: 11px; font-weight: 700; color: var(--red); background: var(--red-soft);
  border-radius: 999px; padding: 3px 9px;
}
.topbar-tag.off { color: var(--text-3); background: var(--bg); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user {
  font-size: 12.5px; color: var(--text-2); max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 三栏布局 ---------- */
.layout { flex: 1; display: flex; min-height: 0; }

/* =========================================================
   全屏编辑器（点击项目后铺满整个屏幕）
   ========================================================= */
.editor-full {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; flex-direction: column;
}
.ef-topbar {
  height: var(--topbar-h); flex-shrink: 0; background: var(--card);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 18px; gap: 12px;
}
.ef-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ef-title {
  font-size: 15px; font-weight: 800; letter-spacing: -.2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px;
}
.ef-tag {
  flex-shrink: 0; font-size: 11px; font-weight: 700; color: var(--red);
  background: var(--red-soft); border-radius: 999px; padding: 3px 9px;
}
.ef-tag.off { color: var(--text-3); background: var(--bg); }
.ef-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ef-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ef-inner { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* 全屏下编辑器占满剩余空间 */
.editor-full .editor { flex: 1; min-height: 0; }
.editor-full .panel.active { padding: 14px 18px 18px; }
.editor-full .builder { min-height: 0; }
.editor-full .canvas { min-height: 0; }
.editor-full .props { flex: 0 0 340px; }
.editor-full .palette { flex: 0 0 190px; }

.side {
  flex: 0 0 258px; background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px; font-size: 13.5px; font-weight: 700;
}
.side-search { padding: 0 14px 10px; }
.side-search input {
  width: 100%; height: 36px; border: 1.5px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--text); padding: 0 12px; font-size: 13px; outline: none;
}
.side-search input:focus { border-color: var(--red); background: #fff; }
.side-list { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.side-foot {
  flex-shrink: 0; padding: 10px 14px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text-3);
}
.side-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius-s); cursor: pointer; transition: .14s;
  border: 1.5px solid transparent;
}
.side-item:hover { background: var(--bg); }
.side-item.active { background: var(--red-soft); border-color: var(--red); }
.side-item-icon {
  width: 34px; height: 34px; border-radius: 11px; background: var(--red-soft);
  display: grid; place-items: center; flex-shrink: 0; overflow: hidden;
}
.side-item.active .side-item-icon { background: #fff; }
.side-item-icon .ico { width: 18px; height: 18px; stroke: var(--red); }
.side-item-icon .custom-icon-img { width: 100%; height: 100%; object-fit: cover; }
.side-item-meta { flex: 1; min-width: 0; }
.side-item-name { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item-desc { font-size: 11.5px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item-cat {
  flex-shrink: 0; font-size: 10.5px; font-weight: 700; color: var(--text-3);
  background: var(--bg); border-radius: 999px; padding: 2px 7px;
}
.side-item.active .side-item-cat { background: #fff; color: var(--red); }
.side-empty { font-size: 12.5px; color: var(--text-3); text-align: center; padding: 26px 10px; line-height: 1.7; }

/* ---------- 中间编辑区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-3); gap: 6px;
}
.ph-icon { font-size: 46px; color: #D8D8DE; line-height: 1; }
.placeholder h2 { font-size: 16px; font-weight: 700; color: var(--text-2); }
.placeholder p { font-size: 13px; }
.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.steps { display: flex; gap: 10px; padding: 14px 18px 0; flex-shrink: 0; }
.step {
  display: flex; align-items: center; gap: 8px; padding: 9px 16px;
  background: var(--card); border-radius: var(--radius-s); box-shadow: var(--shadow-s);
  cursor: pointer; transition: .18s; border: 1.5px solid transparent;
}
.step b {
  width: 20px; height: 20px; border-radius: 50%; background: var(--bg); color: var(--text-3);
  font-size: 11px; display: grid; place-items: center; flex-shrink: 0; transition: .18s;
}
.step span { font-size: 13px; font-weight: 600; color: var(--text-3); }
.step.active { background: var(--red-soft); border-color: var(--red); }
.step.active b { background: var(--red); color: #fff; }
.step.active span { color: var(--red); }
.step.done b { background: #34C77B; color: #fff; }
.step.done span { color: var(--text-2); }

.panel { display: none; }
.panel.active { display: block; flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 18px; }
.panel[data-panel="3"].active { display: flex; flex-direction: column; padding-bottom: 0; overflow: hidden; }

.card {
  background: var(--card); border-radius: var(--radius-m); padding: 16px;
  box-shadow: var(--shadow-s); margin-bottom: 14px;
}
.card-title {
  font-size: 13.5px; font-weight: 700; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.row-gap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.hint-text { font-size: 12px; color: var(--text-3); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.field input[type="text"], .field input[type="number"], .field input[type="email"],
.field input[type="password"], .field textarea, .field select {
  width: 100%; height: 40px; border: 1.5px solid var(--line); border-radius: var(--radius-s);
  background: var(--bg); color: var(--text); padding: 0 12px; font-size: 13.5px;
  outline: none; transition: .16s;
}
.field textarea { height: auto; padding: 10px 12px; line-height: 1.6; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--red); background: #fff; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; min-width: 0; }

.seg { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 10px; flex-wrap: wrap; }
.seg-item {
  flex: 1 1 auto; min-width: 62px; border: none; background: none; font-size: 13px;
  font-weight: 700; color: var(--text-2); padding: 8px 10px; border-radius: 7px;
  cursor: pointer; transition: .16s;
}
.seg-item:hover { color: var(--red); }
.seg-item.active { background: var(--red); color: #fff; box-shadow: var(--shadow-red); }

.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-row { display: flex; gap: 8px; align-items: center; }
.kv-row input {
  flex: 1; min-width: 0; height: 38px; border: 1.5px solid var(--line);
  border-radius: 9px; padding: 0 11px; font-size: 13px; outline: none;
  background: var(--bg); color: var(--text); transition: .16s;
}
.kv-row input:focus { border-color: var(--red); background: #fff; }
.kv-row-param { flex-wrap: wrap; }
.kv-row-param input[data-f="k"] { flex: 1 1 100%; }
.kv-row-param input[data-f="v"] { flex: 1 1 140px; }
.kv-type {
  flex: 0 0 88px; height: 38px; border: 1.5px solid var(--line); border-radius: 9px;
  padding: 0 8px; font-size: 12.5px; outline: none; background: var(--bg); color: var(--text);
}
.kv-type:focus { border-color: var(--red); background: #fff; }
.kv-req {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--text-2); font-weight: 600; cursor: pointer; user-select: none;
}
.kv-req input { width: 16px; height: 16px; accent-color: var(--red); cursor: pointer; }
.kv-del {
  width: 32px; height: 32px; flex-shrink: 0; border: none; border-radius: 9px;
  background: var(--red-soft); color: var(--red); font-size: 18px; line-height: 1;
  cursor: pointer; display: grid; place-items: center;
}
.kv-del:hover { background: var(--red); color: #fff; }
.kv-empty { font-size: 12.5px; color: var(--text-3); padding: 4px 0; }
.mini-add {
  border: none; background: var(--red-soft); color: var(--red); font-size: 12px;
  font-weight: 700; padding: 5px 11px; border-radius: 999px; cursor: pointer;
}
.mini-add:hover { background: var(--red); color: #fff; }

.icon-picker { display: flex; gap: 9px; flex-wrap: wrap; }
.icon-opt {
  width: 44px; height: 44px; border-radius: 13px; background: var(--bg);
  border: 2px solid transparent; display: grid; place-items: center;
  cursor: pointer; transition: .16s; overflow: hidden;
}
.icon-opt .ico { width: 21px; height: 21px; stroke: var(--text-2); }
.icon-opt:hover { background: var(--red-soft); }
.icon-opt.active { background: var(--red-soft); border-color: var(--red); }
.icon-opt.active .ico { stroke: var(--red); }
.icon-opt .custom-icon-img { width: 100%; height: 100%; object-fit: cover; }
.custom-icon-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.api-result { font-size: 12.5px; color: var(--text-2); line-height: 1.6; }
.api-result .field-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.field-tag {
  font-size: 11.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: var(--red-soft); color: var(--red);
}
.run-loading { text-align: center; padding: 22px; color: var(--text-3); font-size: 13px; }
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--red-soft); border-top-color: var(--red);
  border-radius: 50%; margin: 0 auto 10px; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   搭建器（三栏）
   ========================================================= */
.builder { display: flex; gap: 14px; align-items: stretch; flex: 1; min-height: 0; }

.palette {
  flex: 0 0 168px; background: var(--card); border-radius: var(--radius-m);
  box-shadow: var(--shadow-s); padding: 12px 10px; overflow-y: auto;
}
.palette-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 10px;
}
.palette-head .btn.text { font-size: 11.5px; height: auto; padding: 2px 0; }
.palette-group { margin-bottom: 12px; }
.palette-group-title {
  font-size: 10.5px; font-weight: 700; color: var(--text-3);
  letter-spacing: .4px; margin-bottom: 6px;
}
.palette-items { display: flex; flex-direction: column; gap: 6px; }
.palette-item {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  color: var(--text); background: var(--bg); border: 1.5px solid var(--line);
  border-radius: 9px; padding: 8px 9px; cursor: grab; user-select: none; transition: .15s;
}
.palette-item:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.palette-item:active { cursor: grabbing; }
.pi-ico { flex: 0 0 auto; width: 16px; text-align: center; font-size: 11.5px; color: var(--red); }

.canvas-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.canvas-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-3); margin-bottom: 8px; flex-shrink: 0;
}
.canvas-head-title { font-weight: 700; color: var(--text-2); }
/* 画布外层：居中滚动区，内部放手机尺寸的视口。
   完全展开：不设最小高度、不加圆角，撑满可用空间 */
.canvas {
  flex: 1; min-height: 0; overflow: auto;
  border: 1.5px dashed var(--line-2); border-radius: 0;
  padding: 16px; background: var(--bg);
  display: flex; align-items: flex-start; justify-content: center;
}
.canvas-empty { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 90px 10px; }
.canvas.drop-over { border-color: var(--red); border-style: solid; background: var(--red-soft); }

/* 手机视口：宽 375（iPhone 逻辑像素），高 812。
   内部即真实搭建区域，组件宽度以 375 为参照，保证所见即所得 */
.canvas-phone {
  flex: 0 0 auto; width: 375px; height: 812px;
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line-2); border-radius: 0;
  box-shadow: 0 8px 28px rgba(15, 15, 20, .12);
  overflow: hidden;
}
.canvas-phone-bar {
  flex: 0 0 auto; height: 26px; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card); border-bottom: 1px solid var(--line);
  font-size: 10.5px; color: var(--text-3); letter-spacing: .3px;
}
.canvas-phone-bar i {
  width: 34px; height: 4px; border-radius: 999px; background: var(--line-2); font-style: normal;
}
/* 手机屏幕内部：真正的搭建区，可纵向滚动。
   不加水平内边距，让 375px 全部作为组件宽度参照，
   与运行态 .ui-root 撑满屏幕宽度保持一致（所见即所得） */
.canvas-screen {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 0 0 12px; display: flex; flex-direction: column; gap: 10px;
}
.canvas-screen.drop-over { background: var(--red-soft); }

/* 画布节点：只保留内容 + 一个细选中框，不加任何外围装饰 */
.cn {
  position: relative; border-radius: 8px; background: transparent;
  border: 1.5px solid transparent; transition: .15s; cursor: pointer;
}
.cn:hover { border-color: var(--line-2); }
.cn.selected { border-color: var(--red); box-shadow: 0 0 0 2px var(--red-soft); }
.cn-body { padding: 2px; }
/* 子组件容器：排列方向继承容器节点的 layoutDirection（.cn 上输出的 flex-direction），
   这样父组件设「左右」时子组件才能真正横向排列并平分宽度 */
.cn-children {
  display: flex; flex-direction: inherit; gap: 8px;
  padding: 2px;
  /* 包裹层自身撑满容器宽度：容器设 align-items: flex-start 时
     它不会跟着收缩，子组件设 100% / fr 才有正确的参照宽度 */
  align-self: stretch; width: 100%; box-sizing: border-box;
}
.cn-drop-empty {
  font-size: 11.5px; color: var(--text-3); text-align: center;
  padding: 12px; border: 1px dashed var(--line); border-radius: 8px;
}
.cn.drop-over, .cn-children.drop-over { border-color: var(--red); background: var(--red-soft); }
/* 中间包裹层：只负责把父级可用宽度传下去，保持 block，不参与布局计算。
   width: 100% + align-self: stretch 双保险：无论列表的 align-items 是
   flex-start 还是 stretch，它都撑满列表宽度，
   这样卡片设 100% / auto 才能相对列表真实宽度计算 */
.cn-list-body { display: block; width: 100%; padding: 2px; align-self: stretch; box-sizing: border-box; }
.cn-body, .cn-children { box-sizing: border-box; }
.cn { box-sizing: border-box; }

.props {
  flex: 0 0 320px; background: var(--card); border-radius: var(--radius-m);
  box-shadow: var(--shadow-s); display: flex; flex-direction: column; overflow: hidden;
}
.props-head-bar {
  flex-shrink: 0; padding: 12px 14px; font-size: 13px; font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.props-empty { font-size: 12.5px; color: var(--text-3); padding: 30px 18px; text-align: center; line-height: 1.7; }
#propsBody { flex: 1; overflow-y: auto; padding: 14px; }
.props-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 9px; margin-bottom: 12px; border-bottom: 1px solid var(--line);
}
.props-title { font-size: 13.5px; font-weight: 700; }
.props-id { font-size: 10.5px; color: var(--text-3); font-family: ui-monospace, Menlo, monospace; }

.prop-field { margin-bottom: 14px; }
.prop-field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.prop-row { display: flex; align-items: center; gap: 8px; }
.prop-row select, .prop-row input { flex: 1; min-width: 0; }
.prop-field select, .prop-field input[type="text"], .prop-field input[type="number"],
.prop-field textarea {
  width: 100%; height: 38px; border: 1.5px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--text); padding: 0 11px; font-size: 13px;
  outline: none; transition: .16s;
}
.prop-field textarea { height: auto; padding: 9px 11px; line-height: 1.6; resize: vertical; }
.prop-field select:focus, .prop-field input:focus, .prop-field textarea:focus { border-color: var(--red); background: #fff; }
.prop-field input[type="color"] {
  flex: 0 0 44px; width: 44px; height: 38px; padding: 2px;
  border: 1.5px solid var(--line); border-radius: 9px; background: var(--bg); cursor: pointer;
}
.prop-switch { display: flex; align-items: center; justify-content: space-between; }
.prop-switch > label:first-child { margin-bottom: 0; }
.switch-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.switch-wrap input { width: 16px; height: 16px; accent-color: var(--red); cursor: pointer; }
.prop-range { display: flex; align-items: center; gap: 10px; }
.prop-range input[type="range"] { flex: 1; accent-color: var(--red); }
.prop-range-val {
  flex: 0 0 54px; text-align: right; font-size: 12px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.prop-hint { font-size: 11px; color: var(--text-3); margin-top: 5px; line-height: 1.6; }
.prop-preview {
  margin-top: 6px; font-size: 11.5px; color: var(--text-2);
  background: var(--red-soft); border-radius: 8px; padding: 8px 10px;
  line-height: 1.5; word-break: break-all;
}
.prop-preview b { color: var(--red); }

/* 插入式文本 */
.tpl-input { width: 100%; }
.tpl-bar { margin-top: 8px; }
.tpl-bar-tip { font-size: 11px; color: var(--text-3); }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; max-height: 120px; overflow-y: auto; }
.tpl-chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--text-2);
  border-radius: 999px; padding: 4px 10px; font-size: 11.5px; cursor: pointer; line-height: 1.5;
}
.tpl-chip:hover { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.tpl-none { font-size: 11px; color: var(--text-3); }
.tpl-tip { display: block; margin-top: 3px; color: var(--text-3); }

/* =========================================================
   运行态渲染（搭建结果）
   ========================================================= */
.ui-root { display: flex; flex-direction: column; gap: 10px; }
.ui-title { line-height: 1.4; }
.ui-text { line-height: 1.65; }
.ui-img { width: 100%; display: block; background: var(--bg); }
.ui-img-ph, .ui-video-ph {
  width: 100%; border-radius: var(--radius-s); background: var(--red-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--text-3); font-size: 12px;
}
.ui-img-ph .ico, .ui-video-ph .ico { width: 28px; height: 28px; stroke: var(--red); }
.ui-video { width: 100%; display: block; background: #000; }
.ui-divider { width: 100%; }
.ui-btn {
  display: inline-block; background: var(--red); color: #fff; font-weight: 700;
  padding: 9px 20px; cursor: pointer; user-select: none; transition: .15s;
}
.ui-btn:active { opacity: .75; }
.ui-btn-outline { background: transparent; border: 1.5px solid var(--red); color: var(--red); }
.ui-btn-ghost { background: var(--red-soft); color: var(--red); }
.ui-input-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.ui-input-label .req { color: var(--red); margin-left: 2px; }
.ui-input {
  width: 100%; height: 40px; border: 1.5px solid var(--line); background: var(--bg);
  color: var(--text); padding: 0 12px; font-size: 14px; outline: none;
}
.ui-input:focus { border-color: var(--red); }
.ui-input:disabled { opacity: .7; }
.ui-link a { color: var(--red); text-decoration: none; font-weight: 600; }
.ui-link-ph { color: var(--text-3); }
.ui-list-empty {
  font-size: 12.5px; color: var(--text-3); text-align: center;
  padding: 24px 10px; border: 1px dashed var(--line); border-radius: 9px;
}
.empty { text-align: center; padding: 50px 20px; color: var(--text-3); font-size: 13.5px; }
.empty .ico { width: 46px; height: 46px; stroke: #D8D8DE; margin-bottom: 12px; }

/* =========================================================
   预览弹层（手机外框）
   ========================================================= */
.modal-mask {
  position: fixed; inset: 0; z-index: 150; background: rgba(20, 20, 30, .45);
  display: none; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(3px);
}
.modal-mask.show { display: flex; animation: fadeUp .2s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.modal {
  width: 100%; max-width: 420px; max-height: 92vh; background: var(--card);
  border-radius: var(--radius-l); display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
}
.modal-head {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 700;
}
.modal-close {
  width: 30px; height: 30px; border: none; border-radius: 9px; background: var(--bg);
  color: var(--text-2); font-size: 19px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
}
.modal-close:hover { background: var(--red-soft); color: var(--red); }
.modal-body { flex: 1; overflow-y: auto; padding: 18px; background: var(--bg); }
.phone-frame {
  width: 100%; max-width: 340px; margin: 0 auto; background: var(--card);
  border-radius: 26px; padding: 12px; box-shadow: var(--shadow-m);
}
.phone-screen {
  border-radius: 18px; background: var(--card); padding: 14px;
  min-height: 300px; max-height: 62vh; overflow-y: auto;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 60px; transform: translate(-50%, 14px);
  background: rgba(28, 28, 30, .92); color: #fff; font-size: 13.5px; font-weight: 500;
  padding: 11px 20px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: .26s; z-index: 300; white-space: nowrap; max-width: 84%;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #DCDCE2; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #C8C8D0; }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   组件库 3 Tab（组件 / 结构树 / 复用）
   ========================================================= */
.palette-tabs {
  display: flex; gap: 4px; background: var(--bg); padding: 3px;
  border-radius: 9px; margin-bottom: 10px; flex-shrink: 0;
}
.palette-tab {
  flex: 1; border: none; background: none; font-size: 12px; font-weight: 700;
  color: var(--text-2); padding: 6px 4px; border-radius: 7px; cursor: pointer; transition: .16s;
}
.palette-tab:hover { color: var(--red); }
.palette-tab.active { background: var(--red); color: #fff; box-shadow: var(--shadow-red); }
.palette-pane { flex: 1; min-height: 0; overflow-y: auto; }
.palette-empty { font-size: 12px; color: var(--text-3); text-align: center; padding: 24px 8px; line-height: 1.7; }

/* ---------- 结构树 ---------- */
.tree { display: flex; flex-direction: column; gap: 3px; }
.tree-node {
  display: flex; align-items: center; gap: 6px; padding: 6px 7px;
  border-radius: 8px; cursor: pointer; transition: .14s; border: 1.5px solid transparent;
}
.tree-node:hover { background: var(--bg); }
.tree-node.selected { background: var(--red-soft); border-color: var(--red); }
.tree-label {
  flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree-sub { margin-left: 12px; padding-left: 8px; border-left: 1.5px dashed var(--line-2); display: flex; flex-direction: column; gap: 3px; }

/* 结构树右键菜单 */
.tree-menu {
  position: fixed; z-index: 9999; min-width: 132px; padding: 5px;
  background: var(--card); border: 1.5px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16); display: flex; flex-direction: column; gap: 2px;
}
.tree-menu-item {
  border: none; background: transparent; text-align: left; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--text); padding: 7px 10px; border-radius: 7px;
}
.tree-menu-item:hover { background: var(--bg); }
.tree-menu-item.danger { color: var(--red); }
.tree-menu-item.danger:hover { background: var(--red-soft); }

.mini-btn {
  border: none; background: var(--bg); color: var(--text-3); font-size: 11px;
  line-height: 1; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px;
  cursor: pointer; transition: .14s;
}
.mini-btn:hover { background: var(--red-soft); color: var(--red); }
.mini-btn.danger:hover { background: var(--red); color: #fff; }

/* ---------- 复用组件 ---------- */
.reuse-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.reuse-bar .mini-add { font-size: 11.5px; }

/* ---------- 属性面板：分组折叠 ---------- */
.pgroup { border: 1px solid var(--line); border-radius: var(--radius-s); margin-bottom: 10px; overflow: hidden; background: var(--card); }
.pgroup-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 11px; font-size: 12.5px; font-weight: 700; color: var(--text-2);
  background: var(--bg); cursor: pointer; user-select: none; transition: .15s;
}
.pgroup-head:hover { color: var(--red); }
.pgroup-arrow { font-style: normal; font-size: 11px; color: var(--text-3); transition: .2s; }
.pgroup.collapsed .pgroup-arrow { transform: rotate(-90deg); }
.pgroup-body { padding: 12px 11px 4px; }
.pgroup.collapsed .pgroup-body { display: none; }
.pgroup-hint {
  font-size: 11px; color: var(--text-3); line-height: 1.6; margin-bottom: 10px;
  background: var(--bg); border-radius: 8px; padding: 7px 9px;
}
.prop-head-ops { display: flex; align-items: center; gap: 5px; }
.prop-warn {
  font-size: 12px; color: #B26A00; background: #FFF6E5; border-radius: 9px;
  padding: 10px 12px; line-height: 1.65;
}

/* ---------- 四边值 ---------- */
.sides-row { display: flex; flex-direction: column; gap: 8px; }
.sides-split {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--text-2); font-weight: 600; cursor: pointer; user-select: none;
}
.sides-split input { width: 15px; height: 15px; accent-color: var(--red); cursor: pointer; }
.sides-inputs { display: flex; gap: 6px; }
.sides-inputs input {
  flex: 1; min-width: 0; height: 36px; border: 1.5px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--text); padding: 0 9px; font-size: 12.5px; outline: none;
}
.sides-inputs input:focus { border-color: var(--red); background: #fff; }
.sides-inputs.joined input:not(:first-child) { display: none; }

/* ---------- 九宫格位置 ---------- */
.pos-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
  width: 108px; margin-top: 2px;
}
.pos-btn {
  width: 100%; aspect-ratio: 1; border: 1.5px solid var(--line); background: var(--bg);
  border-radius: 7px; cursor: pointer; padding: 0; display: grid; place-items: center; transition: .14s;
}
.pos-btn i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); transition: .14s; }
.pos-btn:hover { border-color: var(--red); }
.pos-btn:hover i { background: var(--red); }
.pos-btn.active { border-color: var(--red); background: var(--red-soft); }
.pos-btn.active i { background: var(--red); }

/* ---------- 插入式文本 ---------- */
.tpl-preview { margin-top: 8px; }

/* =========================================================
   运行态渲染补充（新增组件）
   ========================================================= */
.ui-list { display: flex; flex-direction: column; gap: 10px; }
/* 列表项包裹层：撑满列表宽度，卡片设 100% / auto 时以列表真实宽度为参照 */
.ui-list-item { width: 100%; align-self: stretch; box-sizing: border-box; }
.ui-btn-wrap { display: block; }
.ui-html { line-height: 1.6; }
.ui-richtext { line-height: 1.7; }
.ui-richtext img, .ui-html img { max-width: 100%; }
.ui-rte {
  min-height: 40px; border: 1.5px solid var(--line); background: var(--bg);
  color: var(--text); padding: 9px 12px; font-size: 14px; outline: none; line-height: 1.6;
}
.ui-rte:focus { border-color: var(--red); }
.ui-rte:empty::before { content: attr(data-ph); color: var(--text-3); }
.ui-select { appearance: auto; }
.ui-picker {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 88px; border: 1.5px dashed var(--line-2); border-radius: var(--radius-s);
  background: var(--bg); cursor: pointer; overflow: hidden; transition: .15s;
}
.ui-picker:hover { border-color: var(--red); background: var(--red-soft); }
.ui-picker img, .ui-picker video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ui-pick-ph {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: var(--text-3); font-size: 12px;
}
.ui-pick-ph .ico { width: 24px; height: 24px; stroke: var(--red); }
.ui-pick-ph i { font-style: normal; }
.ui-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.ui-switch-box {
  width: 42px; height: 24px; border-radius: 999px; background: var(--line-2);
  position: relative; transition: .18s; flex-shrink: 0;
}
.ui-switch-box::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: .18s;
}
.ui-switch-box.on { background: var(--red); }
.ui-switch-box.on::after { left: 20px; }
.ui-switch-label { font-size: 13.5px; color: var(--text); }
.ui-progress-wrap { display: flex; align-items: center; gap: 10px; }
.ui-progress { flex: 1; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.ui-progress i { display: block; height: 100%; background: var(--red); border-radius: 999px; }
.ui-progress-txt { flex-shrink: 0; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ui-calendar { border: 1.5px solid var(--line); border-radius: var(--radius-s); padding: 10px; background: var(--card); }
.ui-cal-head { font-size: 13px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.ui-cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.ui-cal-week span { font-size: 11px; color: var(--text-3); text-align: center; }
.ui-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.ui-cal-cell {
  aspect-ratio: 1; display: grid; place-items: center; font-size: 12px;
  color: var(--text); border-radius: 7px;
}
.ui-cal-cell.empty { visibility: hidden; }
.ui-cal-cell.today { background: var(--red); color: #fff; font-weight: 700; }
.ui-lottie { display: grid; place-items: center; min-height: 80px; }
.ui-lottie-ph {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: var(--text-3); font-size: 12px;
}
.ui-lottie-ph .ico { width: 26px; height: 26px; stroke: var(--red); }
.ui-lottie-ph i { font-style: normal; }

/* ---------- 画布节点状态 ---------- */
.cn-unknown { border-color: #F0C36D; background: #FFFBF2; }
.cn-unknown-body { font-size: 11.5px; color: #B26A00; padding: 9px; line-height: 1.6; }
.cn.cn-hidden { opacity: .45; }
.cn.cn-locked { cursor: default; }
.cn-list { border-style: dashed; }

/* ---------- 窄屏兜底 ---------- */
@media (max-width: 1180px) {
  .props { flex: 0 0 280px; }
  .palette { flex: 0 0 148px; }
}
@media (max-width: 980px) {
  .side { flex: 0 0 210px; }
  .builder { flex-wrap: wrap; }
  .props { flex: 1 1 100%; max-height: 320px; }
}

