/* ==========================================================
 * ui-design-guide configurator · 小程序设计工作台
 * 5 栏布局：组件库 / 节点树 / 画布 / 属性 / Vibe
 * ========================================================== */

:root {
  --shell-bg:    #f4f6f8;
  --shell-fg:    #1a1a1a;
  --shell-side:  #fff;
  --shell-border:#e5e7eb;
  --shell-muted: #6b7280;
  --shell-accent:  #07c160;
  --shell-accent-2:#06ad56;
  --shell-danger:  #fa5151;
  --shell-warn:    #ffc300;
  --shell-info:    #10aeff;
}
[data-theme="dark"] {
  --shell-bg: #0f1115; --shell-fg: #e5e7eb; --shell-side: #1a1d24;
  --shell-border: #2a2f3a; --shell-muted: #9ca3af;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", system-ui, sans-serif;
  background: var(--shell-bg); color: var(--shell-fg);
  font-size: 13px;
}
.muted { color: var(--shell-muted); }
.grow  { flex: 1; }

.app { display: grid; grid-template-rows: 48px 34px 1fr 28px; height: 100vh; }

/* ============ Topbar ============ */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--shell-side);
  border-bottom: 1px solid var(--shell-border);
}
.topbar .brand { font-weight: 600; font-size: 13px; white-space: nowrap; }
.topbar select, .topbar input[type="text"], .topbar .tool, .topbar label.tool {
  height: 28px; padding: 0 10px;
  background: var(--shell-bg); border: 1px solid var(--shell-border);
  border-radius: 5px; color: var(--shell-fg); font: inherit; cursor: pointer;
  font-size: 12px;
}
.topbar label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.topbar label.tool { padding: 0 8px; }
.topbar input[type="text"] { width: 180px; cursor: text; }
.topbar-group { display: inline-flex; gap: 4px; align-items: center; padding: 0 6px; border-right: 1px solid var(--shell-border); }
.topbar-group:last-of-type { border-right: 0; }
.topbar .tool.primary { background: var(--shell-accent); border-color: transparent; color: #fff; }
.topbar .tool.primary:hover { background: var(--shell-accent-2); }
.topbar .tool:disabled { opacity: .35; cursor: not-allowed; }

/* ============ Pages Bar ============ */
.pages-bar {
  background: var(--shell-side); border-bottom: 1px solid var(--shell-border);
  padding: 0 8px; display: flex; align-items: center;
  overflow-x: auto;
}
.pages-scroll { display: inline-flex; gap: 2px; align-items: center; }
.page-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 5px 5px 0 0;
  font-size: 12px; cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; border-bottom: 0;
  color: var(--shell-muted);
}
.page-tab:hover { background: var(--shell-bg); }
.page-tab.active {
  background: var(--shell-bg); border-color: var(--shell-border);
  color: var(--shell-fg); font-weight: 500;
}
.page-close { opacity: .4; font-size: 14px; padding: 0 2px; }
.page-close:hover { opacity: 1; color: var(--shell-danger); }
.page-add {
  height: 24px; width: 24px; padding: 0; margin-left: 4px;
  background: var(--shell-bg); border: 1px dashed var(--shell-border);
  border-radius: 5px; cursor: pointer; font-size: 14px;
}

/* ============ Body 5 栏 ============ */
.body {
  display: grid;
  grid-template-columns: 200px 180px 1fr 280px 200px;
  overflow: hidden;
}
.panel {
  background: var(--shell-side);
  border-right: 1px solid var(--shell-border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel.right-2 { border-right: 0; }
.panel.center  { background: var(--shell-bg); }
.panel-header {
  padding: 8px 12px; font-size: 11px; font-weight: 600;
  color: var(--shell-muted); text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--shell-border);
}
.panel-search {
  width: calc(100% - 16px); margin: 8px; padding: 4px 8px;
  border: 1px solid var(--shell-border); background: var(--shell-bg);
  border-radius: 4px; font-size: 12px; color: var(--shell-fg);
}
.panel-content { padding: 8px; }
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }

/* ============ 左1 组件库 ============ */
.comp-tile:hover {
  border-color: var(--shell-accent) !important;
  background: var(--shell-bg) !important;
}
.comp-tile[draggable="true"]:active { cursor: grabbing; }

/* ============ 左2 节点树 ============ */
.tree-item:hover { background: var(--shell-bg); }

/* ============ 中 画布 ============ */
.preview-area {
  flex: 1; position: relative;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px;
  overflow: auto;
}
#preview-root {
  position: relative;
  --color-primary-500: #07c160; --color-primary-600: #06ad56;
  --color-neutral-50: #fafafa; --color-neutral-100: #f7f7f7; --color-neutral-200: #ededed;
  --color-neutral-500: #888; --color-neutral-700: #3d3d3d; --color-neutral-900: #111;
  --color-danger-500: #fa5151; --color-warning-500: #ffc300; --color-info-500: #10aeff;
  --weui-brand: #07c160; --weui-link: #576b95; --weui-red: #fa5151;
  --weui-orange: #fa9d3b; --weui-indigo: #1485ee;
  --weui-bg-0: #ededed; --weui-bg-1: #f7f7f7; --weui-bg-2: #ffffff;
  --weui-fg-0: #000; --weui-fg-1: rgba(0,0,0,.55); --weui-fg-2: rgba(0,0,0,.3);
  --weui-separator: rgba(0,0,0,.1);
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 8px rgba(0,0,0,.08);
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:16px;
  --font-size-xs:11px; --font-size-sm:13px; --font-size-base:15px; --font-size-lg:17px; --font-size-xl:20px; --font-size-2xl:24px; --font-size-3xl:30px;
  --weight-regular:400; --weight-medium:500; --weight-semibold:600; --weight-bold:700;
  --dur-fast:150ms; --dur-base:250ms;
  --ease-standard: cubic-bezier(.2,0,0,1);
}
#preview-root[data-theme="dark"] {
  --weui-bg-0: #111; --weui-bg-1: #1a1a1a; --weui-bg-2: #222;
  --weui-fg-0: #fff; --weui-fg-1: rgba(255,255,255,.55); --weui-fg-2: rgba(255,255,255,.3);
  --weui-separator: rgba(255,255,255,.1);
}

[data-device="desktop"] .mp-simulator {
  width: 100%; max-width: 100%; min-height: 600px;
  border-radius: 12px; border: 1px solid var(--shell-border);
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.mp-simulator {
  width: 375px; min-height: 667px;
  background: var(--weui-bg-1);
  border-radius: 40px;
  border: 8px solid #1a1a1a;
  box-shadow: 0 20px 60px rgba(0,0,0,.25), 0 0 0 2px #333 inset;
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
}
.mp-statusbar {
  height: 36px; background: var(--weui-bg-2);
  display: flex; align-items: center; padding: 0 16px;
  font-size: 12px; font-weight: 500; color: var(--weui-fg-0);
  flex-shrink: 0;
}
.mp-statusbar .time { flex: 1; }
.mp-statusbar .icons { display: flex; gap: 4px; }
.mp-content {
  flex: 1; overflow-y: auto; background: var(--weui-bg-1);
  min-height: 200px; position: relative;
}
.node-container { min-height: 40px; }
.node-container:empty::before {
  content: '拖拽组件到此'; color: var(--weui-fg-2); font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  min-height: 80px;
}

/* 选中框 / 悬浮框 */
.canvas-overlay {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
}

/* ============ 组件预览区域（固定在组件库底部） ============ */
.comp-preview-area {
  border-top: 1px solid var(--shell-border);
  background: var(--shell-side);
  display: flex;
  flex-direction: column;
  min-height: 200px;
  max-height: 280px;
}
.comp-preview-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--shell-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--shell-border);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.comp-preview-body {
  flex: 1;
  overflow: auto;
  padding: 8px;
  background: #ffffff;
}
/* 预览视口：模拟小程序页面宽度 */
.comp-preview-body .preview-viewport {
  width: 375px;
  min-height: 40px;
  margin: 0 auto;
  overflow-x: hidden;
}

/* ============ WeUI 组件样式（给画布中的组件用） ============ */
.weui-cells { background: var(--weui-bg-2); }
.weui-cell {
  display: flex; align-items: center; padding: 12px 16px; min-height: 44px;
  border-bottom: 1px solid var(--weui-separator); gap: 8px;
}
.weui-cell:last-child { border-bottom: none; }
.weui-cell__bd { flex: 1; font-size: 15px; color: var(--weui-fg-0); }
.weui-cell__ft { color: var(--weui-fg-2); font-size: 14px; display: flex; align-items: center; gap: 4px; }

.weui-btn {
  display: flex; align-items: center; justify-content: center;
  width: calc(100% - 32px); margin: 0 auto; height: 44px;
  border-radius: var(--radius-md); font-size: 16px; font-weight: 500;
  border: none; cursor: pointer; transition: opacity .2s;
  font-family: inherit;
}
.weui-btn:active { opacity: .7; }
.weui-btn-primary { background: var(--weui-brand); color: #fff; }
.weui-btn-default { background: var(--weui-bg-2); color: var(--weui-brand); border: 1px solid var(--weui-brand); }
.weui-btn-warn    { background: var(--weui-red); color: #fff; }
.weui-btn-mini { display: inline-flex; width: auto; padding: 0 16px; height: 32px; font-size: 13px; border-radius: 6px; margin: 0; }

.weui-form-cell {
  display: flex; align-items: center; padding: 10px 16px;
  background: var(--weui-bg-2);
  border-bottom: 1px solid var(--weui-separator);
}
.weui-form-label { width: 80px; font-size: 15px; color: var(--weui-fg-0); flex-shrink: 0; }
.weui-form-input {
  flex: 1; border: 0; background: transparent;
  font-size: 15px; color: var(--weui-fg-0); outline: none;
  font-family: inherit;
}
.weui-form-input::placeholder { color: var(--weui-fg-2); }

.weui-search-bar { padding: 8px 16px; background: var(--weui-bg-2); display: flex; gap: 8px; align-items: center; }
.weui-search-input {
  flex: 1; height: 32px; background: var(--weui-bg-1); border: 0;
  border-radius: 6px; padding: 0 12px 0 32px; font-size: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center; background-size: 14px;
}

.weui-msg { display: flex; flex-direction: column; align-items: center; padding: 40px 24px; text-align: center; }
.weui-msg__title { font-size: 18px; font-weight: 500; color: var(--weui-fg-0); margin-bottom: 6px; }
.weui-msg__desc { font-size: 13px; color: var(--weui-fg-1); margin-bottom: 24px; line-height: 1.6; }

.weui-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.weui-tag-green  { background: rgba(7,193,96,.12);   color: var(--weui-brand); }
.weui-tag-orange { background: rgba(250,157,59,.12); color: var(--weui-orange); }
.weui-tag-red    { background: rgba(250,81,81,.12);  color: var(--weui-red); }
.weui-tag-blue   { background: rgba(16,174,255,.12); color: var(--color-info-500); }

.weui-badge { display: inline-block; min-width: 8px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--weui-red); color: #fff; font-size: 11px; line-height: 16px; text-align: center; }
.weui-badge-dot { width: 8px; height: 8px; padding: 0; border-radius: 50%; }

.weui-loading { width: 18px; height: 18px; display: inline-block; border: 2px solid var(--weui-brand); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.weui-skeleton { background: linear-gradient(90deg,var(--weui-bg-0) 25%,rgba(0,0,0,.04) 37%,var(--weui-bg-0) 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.weui-actionsheet__action { padding: 16px; text-align: center; font-size: 16px; color: var(--weui-fg-0); border-bottom: 1px solid var(--weui-separator); cursor: pointer; }
.weui-actionsheet__action.destructive { color: var(--weui-red); }

.weui-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--weui-bg-0); flex-shrink: 0; }
.weui-avatar-sm { width: 32px; height: 32px; }
.weui-avatar-lg { width: 56px; height: 56px; }

.mp-tabbar {
  height: 50px; flex-shrink: 0;
  background: var(--weui-bg-2); border-top: 1px solid var(--weui-separator);
  display: flex; align-items: center; justify-content: space-around;
}
.mp-tabbar-item { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--weui-fg-1); padding: 4px 0; }
.mp-tabbar-item.active { color: var(--weui-brand); }

.mp-capsule { display: inline-flex; align-items: center; border: 1px solid rgba(0,0,0,.15); border-radius: 16px; height: 32px; overflow: hidden; background: rgba(255,255,255,.6); }
.mp-capsule-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.mp-capsule-divider { width: 1px; height: 18px; background: rgba(0,0,0,.15); }

.weui-grid { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--weui-bg-2); padding: 16px 8px; }
.weui-grid-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0; cursor: pointer; }

.mp-swiper { height: 140px; margin: 8px 12px; border-radius: 8px; overflow: hidden; position: relative; }
.mp-swiper-dots { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
.mp-swiper-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.4); }
.mp-swiper-dot.active { background: #fff; width: 16px; border-radius: 3px; }

.mp-goods-card { background: var(--weui-bg-2); border-radius: 8px; overflow: hidden; cursor: pointer; }
.mp-goods-card__img { width: 100%; aspect-ratio: 1; background: var(--weui-bg-0); display: flex; align-items: center; justify-content: center; color: var(--weui-fg-2); font-size: 24px; }
.mp-goods-card__info { padding: 8px 10px; }
.mp-goods-card__title { font-size: 13px; color: var(--weui-fg-0); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mp-goods-card__price { font-size: 15px; color: var(--weui-red); font-weight: 600; margin-top: 4px; }

/* ============ 属性面板 ============ */
.pp-header {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--shell-border);
  background: var(--shell-side); position: sticky; top: 0; z-index: 2;
}
.pp-icon { font-size: 18px; }
.pp-id { font-size: 10px; font-family: monospace; }
.pp-action {
  height: 24px; width: 24px; padding: 0;
  background: var(--shell-bg); border: 1px solid var(--shell-border);
  border-radius: 4px; font-size: 14px; cursor: pointer;
}
.pp-action:hover { background: var(--shell-danger); color: #fff; }

.pp-tabs {
  display: flex; gap: 2px; padding: 6px 8px;
  border-bottom: 1px solid var(--shell-border); background: var(--shell-bg);
}
.pp-tabs button {
  flex: 1; padding: 5px 8px; background: transparent; border: 0;
  color: var(--shell-fg); cursor: pointer; border-radius: 4px; font-size: 12px;
}
.pp-tabs button.on { background: var(--shell-accent); color: #fff; font-weight: 500; }

.pp-body { padding: 10px; }
.pp-field { margin-bottom: 8px; }
.pp-label { display: block; font-size: 11px; color: var(--shell-muted); margin-bottom: 3px; }
.pp-input {
  width: 100%; padding: 4px 8px; background: var(--shell-bg);
  border: 1px solid var(--shell-border); border-radius: 4px;
  color: var(--shell-fg); font: inherit; font-size: 12px;
}
.pp-input:focus { outline: none; border-color: var(--shell-accent); box-shadow: 0 0 0 2px rgba(7,193,96,.15); }
.pp-color { display: flex; gap: 4px; }
.pp-color input[type="color"] { width: 32px; height: 26px; padding: 0; cursor: pointer; border: 1px solid var(--shell-border); border-radius: 4px; }
.pp-color input[type="text"] { flex: 1; }
.pp-empty { padding: 20px; color: var(--shell-muted); text-align: center; font-size: 12px; }
.pp-cat { cursor: pointer; font-weight: 500; padding: 6px 4px; color: var(--shell-muted); font-size: 11px; }
.pp-effects-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; }
.pp-effect-chip {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border: 1px solid var(--shell-border); background: var(--shell-bg);
  border-radius: 4px; cursor: pointer; font-size: 10px;
  transition: border-color .2s;
}
.pp-effect-chip input { display: none; }
.pp-effect-chip.on { border-color: var(--shell-accent); background: rgba(7,193,96,.05); }
.pp-effect-preview { height: 40px; display: flex; align-items: center; justify-content: center; }
.pp-effect-name { color: var(--shell-muted); text-align: center; }

/* ============ Vibe Panel ============ */
.vibe-grid { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 8px; }
.vibe-chip {
  padding: 6px 8px; background: var(--shell-bg); border: 1px solid var(--shell-border);
  border-radius: 4px; cursor: pointer; font-size: 11px; text-align: left;
}
.vibe-chip:hover { border-color: var(--shell-accent); }
.vibe-chip strong { display: block; font-size: 11px; }
.vibe-chip span { color: var(--shell-muted); font-size: 10px; }
.hint { font-size: 10px; color: var(--shell-muted); margin: 8px; padding: 6px; background: var(--shell-bg); border-radius: 4px; min-height: 20px; white-space: pre-line; }

/* ============ Footer ============ */
.footer {
  padding: 4px 12px; font-size: 11px;
  background: var(--shell-side); border-top: 1px solid var(--shell-border);
  display: flex; align-items: center; gap: 12px;
}
.validation { margin-left: auto; }
.validation.ok { color: var(--shell-accent); }
.validation.warn { color: var(--shell-warn); }
.validation.error { color: var(--shell-danger); }

/* ============ 代码导出 Modal ============ */
.code-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
}
.code-modal-inner {
  width: 90%; max-width: 800px; height: 80vh;
  background: var(--shell-side); border-radius: 8px;
  display: flex; flex-direction: column; overflow: hidden;
}
.code-modal-header {
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--shell-border);
}
.code-tabs { display: flex; gap: 2px; flex: 1; }
.code-tabs button {
  padding: 4px 10px; border: 1px solid var(--shell-border); background: var(--shell-bg);
  border-radius: 4px; cursor: pointer; font-size: 12px; color: var(--shell-fg);
}
.code-tabs button.on { background: var(--shell-accent); color: #fff; border-color: transparent; }
.code-close { background: transparent; border: 0; font-size: 20px; cursor: pointer; padding: 0 6px; color: var(--shell-fg); }
.code-pane {
  flex: 1; margin: 0; padding: 16px;
  font-family: "JetBrains Mono", Menlo, monospace; font-size: 11px;
  background: var(--shell-bg); overflow: auto; white-space: pre; line-height: 1.6;
}
.code-modal-footer { padding: 10px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--shell-border); }

/* ============ 空画布引导 ============ */
.empty-guide {
  min-height: 400px; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.empty-guide-inner {
  max-width: 480px; text-align: center;
  background: rgba(7,193,96,0.04);
  border: 2px dashed rgba(7,193,96,0.3);
  border-radius: 12px; padding: 40px 32px;
}
.empty-guide-icon { font-size: 48px; margin-bottom: 12px; }
.empty-guide-title { margin: 0 0 8px; font-size: 18px; color: var(--shell-fg, #333); }
.empty-guide-hint { margin: 0 0 20px; font-size: 13px; color: var(--shell-fg-2, #666); line-height: 1.6; }
.empty-guide-hint b { color: var(--shell-accent, #07C160); }
.empty-guide-templates {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px; margin-bottom: 16px;
}
.empty-guide-templates button {
  padding: 10px 8px; font-size: 12px;
  border: 1px solid rgba(7,193,96,0.3);
  background: #fff; border-radius: 8px; cursor: pointer;
  transition: all 0.15s; color: #333;
}
.empty-guide-templates button:hover {
  border-color: var(--shell-accent, #07C160);
  background: rgba(7,193,96,0.08);
  transform: translateY(-1px);
}
.empty-guide-tip {
  font-size: 11px; color: var(--shell-fg-3, #999);
  padding-top: 12px; border-top: 1px dashed rgba(0,0,0,0.06);
  line-height: 1.8;
}
.empty-guide-tip kbd {
  background: #f5f5f5; padding: 1px 5px; border-radius: 3px;
  border: 1px solid #ddd; font-family: inherit; font-size: 10px;
  box-shadow: 0 1px 0 #ddd;
}

/* ============ 画布选中/悬浮框（canvas.js 会覆盖，此处仅做兜底） ============ */
.canvas-box-selected { border-color: var(--shell-accent, #07C160) !important; }
.canvas-box-hover    { border-color: rgba(7,193,96,0.6) !important; }
.canvas-handle:hover { background: var(--shell-accent, #07C160) !important; }

/* ============ Toast 内部提示 ============ */
.ui-toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 13px; z-index: 9999;
  animation: toastIn 0.2s ease;
}
.ui-toast.error   { background: rgba(200,30,30,0.9); }
.ui-toast.success { background: rgba(7,193,96,0.9); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Confirm 对话框 */
.ui-confirm-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
  animation: fadeIn 0.15s ease;
}
.ui-confirm {
  background: #fff; border-radius: 12px; min-width: 280px; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2); overflow: hidden;
}
.ui-confirm-msg { padding: 24px 20px; font-size: 14px; color: #333; line-height: 1.6; text-align: center; }
.ui-confirm-footer {
  display: flex; border-top: 1px solid #eee;
}
.ui-confirm-footer button {
  flex: 1; padding: 14px 0; border: 0; background: #fff; cursor: pointer; font-size: 14px;
  border-right: 1px solid #eee;
}
.ui-confirm-footer button:last-child { border-right: 0; }
.ui-confirm-footer .btn-cancel { color: #666; }
.ui-confirm-footer .btn-ok { color: var(--shell-accent, #07C160); font-weight: 500; }
.ui-confirm-footer .btn-ok.danger { color: #e54545; }
.ui-confirm-footer button:hover { background: #fafafa; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============ 间距盒子（padding/margin 可视化） ============ */
.spacing-box { padding: 8px 0; }
.sb-margin {
  position: relative;
  background: rgba(255,152,0,0.08);
  border: 1px dashed rgba(255,152,0,0.4);
  padding: 22px;
  border-radius: 4px;
}
.sb-padding {
  position: relative;
  background: rgba(7,193,96,0.1);
  border: 1px dashed rgba(7,193,96,0.5);
  padding: 22px;
  border-radius: 4px;
}
.sb-tag {
  position: absolute; top: 2px; left: 4px;
  font-size: 9px; color: rgba(0,0,0,0.5);
  font-family: Menlo, monospace;
}
.sb-center {
  background: rgba(255,255,255,0.9);
  padding: 10px;
  text-align: center;
  font-size: 11px;
  color: #666;
  border-radius: 3px;
}
.sb-input {
  position: absolute;
  width: 32px; height: 18px;
  font-size: 10px; text-align: center;
  border: 1px solid rgba(0,0,0,0.1);
  background: #fff;
  border-radius: 2px;
  padding: 0 2px;
  font-family: Menlo, monospace;
}
.sb-input:focus { outline: 1px solid var(--shell-accent, #07C160); border-color: transparent; }
.sb-m-t { top: 2px; left: calc(50% - 16px); }
.sb-m-r { right: 2px; top: calc(50% - 9px); }
.sb-m-b { bottom: 2px; left: calc(50% - 16px); }
.sb-m-l { left: 2px; top: calc(50% - 9px); }
.sb-p-t { top: 2px; left: calc(50% - 16px); }
.sb-p-r { right: 2px; top: calc(50% - 9px); }
.sb-p-b { bottom: 2px; left: calc(50% - 16px); }
.sb-p-l { left: 2px; top: calc(50% - 9px); }

/* ============ 工程管理器 ============ */
.pm-mask { z-index: 9998; }
.pm-panel {
  background: #fff; border-radius: 12px; width: 720px; max-width: 94vw;
  max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2); overflow: hidden;
}
.pm-header {
  padding: 14px 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid #eee; background: #fafafa;
}
.pm-header strong { font-size: 15px; }
.pm-actions { display: flex; gap: 8px; flex: 1; justify-content: flex-end; }
.pm-actions input {
  padding: 6px 10px; border: 1px solid #ddd; border-radius: 6px;
  font-size: 13px; width: 180px;
}
.pm-list { flex: 1; overflow: auto; padding: 8px; }
.pm-empty { padding: 60px 20px; text-align: center; color: #999; font-size: 13px; }
.pm-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border-radius: 8px; border: 1px solid transparent;
  transition: all 0.15s; cursor: default;
}
.pm-item:hover { background: #f7f7f7; border-color: #eee; }
.pm-thumb {
  width: 48px; height: 48px; border-radius: 8px;
  background: linear-gradient(135deg, rgba(7,193,96,0.15), rgba(7,193,96,0.05));
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  flex-shrink: 0; overflow: hidden;
}
.pm-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pm-info { flex: 1; min-width: 0; }
.pm-name { font-size: 14px; color: #333; font-weight: 500; margin-bottom: 3px; }
.pm-meta {
  font-size: 11px; color: #999;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.pm-platform {
  background: rgba(7,193,96,0.1); color: var(--shell-accent, #07C160);
  padding: 1px 6px; border-radius: 3px; margin-left: auto;
}
.pm-buttons { display: flex; gap: 6px; flex-shrink: 0; }
.pm-buttons button {
  padding: 6px 12px; font-size: 12px; border: 1px solid #ddd;
  background: #fff; border-radius: 5px; cursor: pointer; color: #333;
}
.pm-buttons button:hover { border-color: var(--shell-accent, #07C160); color: var(--shell-accent, #07C160); }
.pm-buttons .pm-danger:hover { border-color: #fa5151; color: #fa5151; }
.pm-footer {
  padding: 12px 18px; display: flex; align-items: center; gap: 12px;
  border-top: 1px solid #eee; background: #fafafa;
}
.pm-tip { font-size: 11px; color: #999; flex: 1; text-align: right; }

/* ============ 尺寸字段（px/%/auto 切换） ============ */
.pp-dim { display: flex; gap: 4px; align-items: stretch; }
.pp-dim-num { flex: 1; min-width: 0; }
.pp-dim-num:disabled { background: #f5f5f5; color: #ccc; }
.pp-dim-units { display: flex; border: 1px solid var(--shell-border); border-radius: 4px; overflow: hidden; }
.pp-dim-unit {
  border: 0; background: var(--shell-side); padding: 0 6px;
  font-size: 10px; cursor: pointer; color: var(--shell-muted);
  border-right: 1px solid var(--shell-border); min-width: 28px;
}
.pp-dim-unit:last-child { border-right: 0; }
.pp-dim-unit.on { background: var(--shell-accent); color: #fff; }
.pp-dim-unit:hover:not(.on) { background: rgba(7,193,96,0.08); }

/* ============ Tokens 差异对比 ============ */
.td-panel {
  background: #fff; border-radius: 12px; width: 720px; max-width: 94vw;
  max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2); overflow: hidden;
}
.td-header {
  padding: 14px 18px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #eee; background: #fafafa;
}
.td-header strong { font-size: 15px; }
.td-header .muted { font-size: 12px; color: #999; margin-right: auto; }
.td-body { flex: 1; overflow: auto; padding: 12px; }
.td-empty { padding: 60px; text-align: center; color: #999; }
.td-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.td-table th, .td-table td {
  padding: 8px 10px; border-bottom: 1px solid #f0f0f0; text-align: left;
}
.td-table th { background: #fafafa; font-weight: 500; color: #666; }
.td-table code { background: #f5f5f5; padding: 1px 5px; border-radius: 3px; font-family: Menlo, monospace; }
.td-path { font-family: Menlo, monospace; color: var(--shell-accent); font-size: 11px; }
.td-old { color: #999; }
.td-new { color: #333; }
.td-color-cell { display: inline-flex; align-items: center; gap: 6px; }
.td-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); display: inline-block; }
.td-footer {
  padding: 12px 18px; display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid #eee; background: #fafafa;
}

/* ============ 代码语法高亮 ============ */
.code-pane.hl .hl-tag     { color: #e06c75; }
.code-pane.hl .hl-attr    { color: #d19a66; }
.code-pane.hl .hl-string  { color: #98c379; }
.code-pane.hl .hl-comment { color: #7f848e; font-style: italic; }
.code-pane.hl .hl-keyword { color: #c678dd; font-weight: 500; }
.code-pane.hl .hl-num     { color: #d19a66; }
.code-pane.hl .hl-punc    { color: #abb2bf; }
.code-pane.hl {
  background: #282c34; color: #abb2bf;
}

/* ============ 分享对话框 ============ */
.share-panel {
  background: #fff; border-radius: 12px; width: 640px; max-width: 94vw;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2); overflow: hidden;
  display: flex; flex-direction: column;
}
.share-header {
  padding: 14px 18px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #eee; background: #fafafa;
}
.share-header strong { font-size: 15px; flex: 1; }
.share-body { display: flex; gap: 16px; padding: 20px; }
.share-qr {
  width: 220px; height: 220px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid #eee; border-radius: 8px;
}
.share-qr svg { display: block; }
.share-qr-err { text-align: center; color: #999; font-size: 13px; padding: 20px; }
.share-info { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.share-label { font-size: 12px; color: #666; font-weight: 500; }
.share-url {
  width: 100%; padding: 8px 10px; font-family: Menlo, monospace;
  font-size: 11px; border: 1px solid #eee; border-radius: 4px;
  background: #fafafa; resize: none; color: #555;
}
.share-tips {
  font-size: 11px; color: #999; line-height: 1.8;
  padding: 8px 10px; background: #f7f7f7; border-radius: 4px;
  margin-top: auto;
}
.share-footer {
  padding: 12px 18px; display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid #eee; background: #fafafa;
}

/* ============ AI 生成对话框 ============ */
.ai-panel {
  background: #fff; border-radius: 12px; width: 520px; max-width: 94vw;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2); overflow: hidden;
  display: flex; flex-direction: column;
}
.ai-header {
  padding: 14px 18px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid #eee; background: linear-gradient(135deg, rgba(100,103,240,0.08), rgba(7,193,96,0.08));
}
.ai-header strong { font-size: 15px; flex: 1; }
.ai-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.ai-label { font-size: 12px; color: #666; font-weight: 500; }
.ai-input {
  padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px;
  font-size: 13px; outline: none; font-family: inherit; resize: vertical;
}
.ai-input:focus { border-color: var(--shell-accent, #07C160); }
textarea.ai-input { line-height: 1.6; }
.ai-samples { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-sample-tag {
  padding: 4px 10px; background: #f0f0f0; border-radius: 4px;
  font-size: 11px; color: #666; cursor: pointer;
}
.ai-sample-tag:hover { background: rgba(7,193,96,0.1); color: var(--shell-accent, #07C160); }
.ai-hint {
  font-size: 11px; color: #666; padding: 8px 10px;
  background: #fafafa; border-radius: 4px; line-height: 1.6;
}
.ai-footer {
  padding: 12px 18px; display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid #eee; background: #fafafa;
}

/* 插件列表 */
.pl-list { display: flex; flex-direction: column; gap: 6px; }
.pl-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: #fafafa; border-radius: 6px;
  border: 1px solid #f0f0f0;
}
.pl-name { font-size: 13px; font-weight: 500; color: #333; }
.pl-desc { font-size: 11px; color: #888; margin-top: 2px; }

/* ============ 响应式 ============ */
@media (max-width: 1400px) {
  .body { grid-template-columns: 180px 160px 1fr 260px 180px; }
}
@media (max-width: 1200px) {
  .body { grid-template-columns: 160px 140px 1fr 240px; }
  .right-2 { display: none; }
}
