/* ============================================================================
 * 文件说明: 工业级高清晰度设计系统样式表 (src/styles/editor.css)
 * 设计规范:
 *   1. 工业中性暗色灰阶 (Graphite / Zinc)，低反差沉稳底色 + 1px 精细分界
 *   2. 全局 dark color-scheme 与 6px 暗色自定义滚动条，彻底消除白底滚动条割裂感
 *   3. 紧凑精准的 Figma/VS Code 级表单控件（内嵌单位输入框、分段控制条、透明网格色板）
 * ============================================================================ */

:root {
  color-scheme: dark;

  /* 工业级基础调色板 */
  --bg-canvas-wrap: #0f0f12;  /* 最深画布视口底色 */
  --bg-app: #161619;          /* 最底层工作区 */
  --bg-sidebar: #1b1b1f;      /* 侧边栏与工具栏 */
  --bg-panel: #212126;        /* 次级面板与分组卡片 */
  --bg-panel-hover: #292930;  /* 悬停反馈 */
  --bg-input: #141417;        /* 控件输入凹槽 */

  /* 边框体系 */
  --border-subtle: #27272d;
  --border-main: #32323a;
  --border-focus: #0d8bf2;
  --border-active: #3f3f48;

  /* 文字体系 */
  --text-title: #f4f4f6;
  --text-main: #d4d4dc;
  --text-muted: #9696a2;
  --text-dim: #666672;

  /* 工业语义强调色 */
  --accent: #0d8bf2;
  --accent-hover: #2599f8;
  --accent-subtle: rgba(13, 139, 242, 0.14);
  --guide-line: #00b4d8;
  --danger: #cf4848;
  --danger-hover: #e05252;
  --danger-bg: rgba(207, 72, 72, 0.14);
  --success: #2ea063;

  /* 几何规范 */
  --radius-xs: 2px;
  --radius-sm: 3px;
  --radius-md: 4px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #36363e transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #35353e;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4b4b56;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ==================== 1. 顶部工业全局工具栏 ==================== */
.topbar {
  height: 42px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  z-index: 100;
  flex-shrink: 0;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.brand-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-title);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-badge {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  font-weight: 500;
  font-family: Consolas, monospace;
  white-space: nowrap;
}

.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 分段工具条容器 */
.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #151518;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  flex-shrink: 0;
}

.toolbar-group .select-compact {
  border: none;
  background: transparent;
  height: 24px;
  padding: 0 6px;
}

.toolbar-group .select-compact:hover {
  background: var(--bg-panel-hover);
}

.toolbar-group .select-zoom {
  width: 60px;
  text-align: center;
  font-family: Consolas, monospace;
  font-size: 11px;
}

/* 按钮体系 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-main);
  background: var(--bg-panel);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.btn:hover:not(:disabled) {
  background: var(--bg-panel-hover);
  border-color: #4a4a54;
  color: var(--text-title);
}

.btn:active:not(:disabled) {
  background: #18181c;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
  flex-shrink: 0;
}

.btn-icon svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.btn-icon:hover:not(:disabled) {
  background: var(--bg-panel-hover);
  color: var(--text-title);
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-subtle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 7px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s ease, color 0.1s ease;
}

.btn-subtle:hover:not(:disabled) {
  background: var(--bg-panel-hover);
  color: var(--text-title);
}

.btn-subtle-danger {
  color: #dc8686;
}

.btn-subtle-danger:hover:not(:disabled) {
  background: var(--danger-bg);
  color: #ffb4b4;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.btn-preview-active {
  background: #1f4f36;
  border-color: #2d7450;
  color: #d9fbe6;
}

.btn-preview-active:hover:not(:disabled) {
  background: #19422c;
  border-color: #36875d;
  color: #ffffff;
}

.btn-danger {
  color: #e49191;
  border-color: rgba(207, 72, 72, 0.4);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #ffb8b8;
}

.select-compact {
  height: 26px;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 11.5px;
  outline: none;
  cursor: pointer;
  white-space: nowrap;
}

.select-compact option {
  background: #1c1c20;
  color: var(--text-main);
}

.select-compact:focus {
  border-color: var(--border-focus);
}

@media (max-width: 1180px) {
  .topbar {
    padding: 0 8px;
    gap: 6px;
  }
  .topbar-center,
  .topbar-right {
    gap: 4px;
  }
  .btn {
    padding: 0 8px;
    font-size: 11.5px;
  }
  .brand-badge {
    display: none;
  }
}

/* ==================== 2. 三栏式工作区架构 ==================== */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* 左侧栏 */
.sidebar-left {
  width: 276px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-main);
  display: flex;
  flex-direction: column;
  z-index: 20;
  flex-shrink: 0;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-main);
  background: #17171a;
  flex-shrink: 0;
  height: 32px;
}

.panel-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-top: 2px solid transparent;
  border-bottom: 1px solid transparent;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}

.panel-tab:hover {
  color: var(--text-main);
}

.panel-tab.active {
  color: var(--text-title);
  border-top-color: var(--accent);
  background: var(--bg-sidebar);
}

.left-content {
  flex: 0 1 auto;
  max-height: 44%;
  overflow-y: auto;
  padding: 10px;
}

.section-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.45;
  padding: 6px 8px;
  background: var(--bg-panel);
  border-radius: var(--radius-xs);
  border-left: 2px solid var(--border-active);
}

.catalog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.catalog-item {
  background: var(--bg-panel);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
  cursor: grab;
  transition: border-color 0.12s, background 0.12s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.catalog-item:hover {
  border-color: #50505c;
  background: var(--bg-panel-hover);
}

.catalog-item:active {
  cursor: grabbing;
}

.catalog-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.catalog-icon-box {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a0a0aa;
  font-family: Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
}

.catalog-icon-box svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.catalog-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-title);
}

.catalog-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ==================== 页面拓扑与逻辑导图 ==================== */
.mindmap-section {
  flex: 1;
  min-height: 180px;
  border-top: 1px solid var(--border-main);
  background: #17171a;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mindmap-header {
  padding: 0 10px;
  background: #19191d;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  height: 30px;
}

.mindmap-header-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-title);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mindmap-count-pill {
  font-size: 10px;
  padding: 0 5px;
  height: 16px;
  line-height: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-family: Consolas, monospace;
  font-weight: 500;
}

.mindmap-header-actions {
  display: flex;
  gap: 4px;
}

.mindmap-mini-btn {
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-xs);
  padding: 1px 6px;
  height: 20px;
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.1s;
}

.mindmap-mini-btn:hover {
  background: var(--bg-panel-hover);
  border-color: #555562;
  color: #fff;
}

.mindmap-viewport {
  flex: 1;
  overflow: auto;
  position: relative;
  padding: 10px;
  background: #141417;
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 16px 16px;
}

/* 左侧边栏内：垂直缩进树形结构，消除横向裁切与多余滚动条 */
#mindmap-viewport {
  overflow-x: hidden;
  overflow-y: auto;
}

#mindmap-viewport .mm-tree-root {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

#mindmap-viewport .mm-branch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

#mindmap-viewport .mm-children {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 16px;
  position: relative;
  width: 100%;
}

#mindmap-viewport .mm-children::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 18px;
  width: 1px;
  background: #383842;
}

#mindmap-viewport .mm-child-row {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
}

#mindmap-viewport .mm-child-row::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 20px;
  width: 10px;
  height: 1px;
  background: #383842;
}

#mindmap-viewport .mm-node {
  width: 100%;
  max-width: none;
  min-width: 0;
}

/* 全景弹窗内：水平展开思维导图树 */
#modal-mindmap-viewport .mm-tree-root {
  display: inline-flex;
  align-items: center;
  min-width: 100%;
  min-height: 100%;
}

#modal-mindmap-viewport .mm-branch {
  display: flex;
  align-items: center;
}

#modal-mindmap-viewport .mm-children {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  position: relative;
  padding-left: 24px;
}

#modal-mindmap-viewport .mm-children::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 12px;
  height: 1px;
  background: #42424c;
}

#modal-mindmap-viewport .mm-child-row {
  position: relative;
  display: flex;
  align-items: center;
}

#modal-mindmap-viewport .mm-child-row::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 12px;
  height: 1px;
  background: #42424c;
}

#modal-mindmap-viewport .mm-child-row:not(:only-child)::after {
  content: "";
  position: absolute;
  left: -12px;
  width: 1px;
  background: #42424c;
}

#modal-mindmap-viewport .mm-child-row:first-child:not(:only-child)::after {
  top: 50%;
  bottom: -10px;
}

#modal-mindmap-viewport .mm-child-row:last-child:not(:only-child)::after {
  top: -10px;
  bottom: 50%;
}

#modal-mindmap-viewport .mm-child-row:not(:first-child):not(:last-child)::after {
  top: -10px;
  bottom: -10px;
}

#modal-mindmap-viewport .mm-node {
  min-width: 156px;
  max-width: 196px;
}

/* 工业级拓扑节点卡片 */
.mm-node {
  background: #1f1f24;
  border: 1px solid #32323a;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
  position: relative;
}

.mm-node:hover {
  border-color: #50505c;
  background: #26262c;
}

.mm-node.active {
  background: #1a2634;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.mm-node.is-root {
  border-left: 3px solid #6b6b78;
}

.mm-node.active.is-root {
  border-left: 3px solid var(--accent);
}

.mm-node-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mm-node-type-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: Consolas, monospace;
  flex-shrink: 0;
}

.mm-node.active .mm-node-type-tag {
  color: #6bb9f0;
}

.mm-node-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.mm-node-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mm-node-actions {
  display: inline-flex;
  gap: 3px;
}

.mm-act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #161619;
  color: var(--text-muted);
  border: 1px solid #35353e;
  border-radius: var(--radius-xs);
  width: 18px;
  height: 18px;
  padding: 0;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.mm-act-btn svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.mm-act-btn:hover {
  background: #2b2b33;
  color: #fff;
  border-color: #50505c;
}

.mm-act-btn.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* 图层列表 */
.layer-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text-main);
}

.layer-item:hover {
  background: var(--bg-panel);
}

.layer-item.active {
  background: rgba(13, 139, 242, 0.15);
  border-color: rgba(13, 139, 242, 0.35);
  color: #e4f2fe;
}

.layer-item.is-hidden {
  opacity: 0.48;
}

.layer-item-title {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.layer-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-type-badge {
  font-size: 9px;
  color: var(--text-dim);
  background: #141417;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 0 3px;
  font-family: Consolas, monospace;
  flex-shrink: 0;
}

.layer-item.active .layer-type-badge {
  color: #79bdf6;
  border-color: rgba(13, 139, 242, 0.35);
}

.layer-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.layer-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-xs);
  padding: 0;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.layer-icon-btn svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.layer-icon-btn:hover {
  color: var(--text-title);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-subtle);
}

.layer-icon-btn.danger:hover {
  color: #ffb4b4;
  background: var(--danger-bg);
  border-color: rgba(207, 72, 72, 0.35);
}

.layer-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  font-size: 10px;
}

.layer-btn:hover {
  color: var(--text-title);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-subtle);
}

/* 底部状态与检查指引栏 */
.feature-guide-box {
  border-top: 1px solid var(--border-main);
  padding: 8px 10px;
  background: #17171a;
  height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex-shrink: 0;
}

.feature-guide-title {
  font-size: 11px;
  font-weight: 600;
  color: #a9a9b3;
  margin-bottom: 3px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feature-guide-body {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  overflow-y: auto;
}

/* ==================== 3. 中央画布工作区 ==================== */
.canvas-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-canvas-wrap);
  position: relative;
}

.canvas-topbar {
  height: 32px;
  background: #17171a;
  border-bottom: 1px solid var(--border-main);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.canvas-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.canvas-crumb-view {
  color: var(--text-title);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.canvas-crumb-sep {
  color: var(--text-dim);
}

.canvas-crumb-meta {
  font-family: Consolas, monospace;
  font-size: 10.5px;
  color: var(--text-muted);
}

.canvas-topbar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.canvas-chip {
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-main);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.1s ease;
}

.canvas-chip:hover {
  color: var(--text-title);
  border-color: #4b4b56;
}

.canvas-chip.active {
  background: rgba(13, 139, 242, 0.14);
  border-color: rgba(13, 139, 242, 0.45);
  color: #7cc4fa;
}

.canvas-viewport {
  flex: 1;
  background: var(--bg-canvas-wrap);
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 24px 24px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 28px 32px;
  position: relative;
}

.canvas-scale-spacer {
  margin: 0 auto;
  position: relative;
  flex-shrink: 0;
}

.canvas-stage-wrapper {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: top left;
}

.canvas-stage {
  background: #ffffff;
  position: relative;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.45),
    0 12px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.09);
  border-radius: 0;
  overflow: hidden;
}

.canvas-stage.show-grid {
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.055) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* 画布元素 */
.canvas-element {
  position: absolute;
  left: 0;
  top: 0;
  cursor: move;
  user-select: none;
  touch-action: none;
  will-change: transform, width, height;
}

.canvas-element.dragging {
  cursor: grabbing;
}

.canvas-stage:not(.preview-mode) .canvas-element:hover {
  outline: 1px dashed rgba(13, 139, 242, 0.6);
}

.canvas-stage:not(.preview-mode) .canvas-element.selected {
  outline: 1px solid rgba(13, 139, 242, 0.35);
}

/* 画布框选选区矩形 (Marquee Selection) */
.canvas-marquee-box {
  position: absolute;
  border: 1px dashed var(--accent);
  background: rgba(13, 139, 242, 0.08);
  pointer-events: none;
  z-index: 9998;
  display: none;
}

/* 成组标识角标 */
.group-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #172536;
  color: #6bb9f0;
  border: 1px solid rgba(13, 139, 242, 0.45);
  font-size: 9px;
  padding: 0 4px;
  border-radius: var(--radius-xs);
  font-family: Consolas, monospace;
  flex-shrink: 0;
}

/* 工业级顶层选中控制框 */
.canvas-selection-overlay {
  position: absolute;
  left: 0;
  top: 0;
  border: 1px solid var(--accent);
  pointer-events: none;
  z-index: 9999;
  display: none;
  will-change: transform, width, height;
}

.canvas-selection-overlay .element-floating-toolbar,
.canvas-selection-overlay .resize-handle {
  pointer-events: auto;
}

.canvas-stage.preview-mode .canvas-element {
  cursor: default;
}

.canvas-stage.preview-mode .canvas-element[data-has-action="true"] {
  cursor: pointer;
}

/* 快捷操作微型面板 */
.element-floating-toolbar {
  position: absolute;
  top: -28px;
  left: 0;
  height: 24px;
  background: #1c1c21;
  color: #d4d4dc;
  border: 1px solid #36363f;
  border-radius: var(--radius-xs);
  padding: 0 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  z-index: 1001;
}

.element-floating-toolbar.pos-bottom {
  top: auto;
  bottom: -28px;
}

.element-floating-toolbar.align-right {
  left: auto;
  right: 0;
}

.floating-coord {
  color: #8ab4d8;
  font-family: Consolas, monospace;
  font-size: 10px;
  padding-right: 5px;
  border-right: 1px solid #32323a;
}

.floating-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px 4px;
  border-radius: var(--radius-xs);
  font-size: 10.5px;
}

.floating-btn:hover {
  background: #2b2b33;
  color: #ffffff;
}

.floating-btn.danger:hover {
  background: var(--danger-bg);
  color: #fca5a5;
}

/* 8 方向高精度缩放手柄 */
.resize-handle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #ffffff;
  border: 1px solid var(--accent);
  border-radius: 0;
  z-index: 1000;
}

.resize-handle.nw { top: -3px; left: -3px; cursor: nwse-resize; }
.resize-handle.n  { top: -3px; left: calc(50% - 3px); cursor: ns-resize; }
.resize-handle.ne { top: -3px; right: -3px; cursor: nesw-resize; }
.resize-handle.e  { top: calc(50% - 3px); right: -3px; cursor: ew-resize; }
.resize-handle.se { bottom: -3px; right: -3px; cursor: nwse-resize; }
.resize-handle.s  { bottom: -3px; left: calc(50% - 3px); cursor: ns-resize; }
.resize-handle.sw { bottom: -3px; left: -3px; cursor: nesw-resize; }
.resize-handle.w  { top: calc(50% - 3px); left: -3px; cursor: ew-resize; }

/* 智能对齐吸附线 */
.snap-guide-v,
.snap-guide-h {
  position: absolute;
  background: var(--guide-line);
  pointer-events: none;
  z-index: 2000;
  display: none;
}

.snap-guide-v {
  top: 0;
  bottom: 0;
  width: 1px;
}

.snap-guide-h {
  left: 0;
  right: 0;
  height: 1px;
}

/* ==================== 4. 右侧属性检查器 (Inspector) ==================== */
.sidebar-right {
  width: 296px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-main);
  display: flex;
  flex-direction: column;
  z-index: 20;
  flex-shrink: 0;
}

.inspector-header {
  height: 32px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #17171a;
  flex-shrink: 0;
}

.inspector-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-title);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.inspector-type-pill {
  font-size: 9.5px;
  font-weight: 500;
  color: #7cc4fa;
  background: rgba(13, 139, 242, 0.14);
  border: 1px solid rgba(13, 139, 242, 0.3);
  border-radius: var(--radius-xs);
  padding: 0 4px;
  height: 16px;
  line-height: 14px;
  font-family: Consolas, monospace;
  flex-shrink: 0;
}

.inspector-id-pill {
  font-size: 10px;
  color: var(--text-dim);
  font-family: Consolas, monospace;
  flex-shrink: 0;
}

.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prop-group {
  background: #18181c;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
}

.prop-group-title {
  font-size: 11px;
  font-weight: 600;
  color: #b4b4be;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: 0.01em;
}

.prop-group-desc {
  font-size: 9.5px;
  color: var(--text-dim);
  font-family: Consolas, monospace;
  font-weight: 400;
}

.prop-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.prop-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
}

.prop-row:last-child {
  margin-bottom: 0;
}

.prop-row-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
  cursor: pointer;
}

.prop-label {
  font-size: 10.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prop-input,
.prop-textarea,
.prop-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-xs);
  color: var(--text-title);
  padding: 4px 7px;
  font-size: 11.5px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.1s;
}

.prop-input,
.prop-select {
  height: 26px;
}

.prop-input:focus,
.prop-textarea:focus,
.prop-select:focus {
  border-color: var(--border-focus);
}

.prop-select option {
  background: #1c1c20;
  color: var(--text-main);
}

.prop-textarea {
  resize: vertical;
  min-height: 48px;
  line-height: 1.45;
}

/* Figma 风格内嵌单位数字输入控件 */
.num-field {
  display: flex;
  align-items: center;
  height: 26px;
  background: var(--bg-input);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-xs);
  padding: 0 6px;
  gap: 5px;
  transition: border-color 0.1s;
}

.num-field:focus-within {
  border-color: var(--border-focus);
}

.num-prefix {
  font-size: 10px;
  color: var(--text-dim);
  font-family: Consolas, monospace;
  flex-shrink: 0;
  user-select: none;
}

.num-field input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-title);
  font-size: 11.5px;
  font-family: Consolas, monospace;
}

/* 分段控制栏（层级顺序 / 对齐方式） */
.seg-group {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-xs);
  overflow: hidden;
  height: 26px;
}

.seg-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 10.5px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.seg-btn:last-child {
  border-right: none;
}

.seg-btn svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.seg-btn:hover {
  background: var(--bg-panel-hover);
  color: var(--text-title);
}

.seg-btn.active {
  background: rgba(13, 139, 242, 0.18);
  color: #7cc4fa;
}

/* 工业级色彩选择器 (支持透明棋盘格预览) */
.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
}

.color-swatch {
  position: relative;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  overflow: hidden;
  cursor: pointer;
}

.color-swatch.is-transparent {
  background-color: #202026 !important;
  background-image:
    linear-gradient(45deg, #2d2d36 25%, transparent 25%),
    linear-gradient(-45deg, #2d2d36 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2d2d36 75%),
    linear-gradient(-45deg, transparent 75%, #2d2d36 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

.color-swatch.is-transparent::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 0.8px),
    #cf4848 calc(50% - 0.8px),
    #cf4848 calc(50% + 0.8px),
    transparent calc(50% + 0.8px)
  );
  pointer-events: none;
}

.color-swatch input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  opacity: 0;
  cursor: pointer;
  border: none;
}

.color-picker {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-xs);
  background: transparent;
  cursor: pointer;
  padding: 0;
}

/* 暗色工业切换开关 */
.toggle-switch {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 16px;
  background: #27272e;
  border: 1px solid #3c3c46;
  border-radius: 99px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8b8b96;
  transition: transform 0.15s, background 0.15s;
}

.toggle-switch:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-switch:checked::after {
  transform: translateX(12px);
  background: #ffffff;
}

/* ==================== 5. 模态弹窗系统 ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 820px;
  max-width: 92vw;
  max-height: 86vh;
  background: #1d1d21;
  border: 1px solid #3c3c45;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #17171a;
}

.modal-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}

.code-pre {
  background: #101012;
  color: #cfd0d6;
  padding: 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-main);
  font-family: Consolas, "Courier New", monospace;
  font-size: 11.5px;
  line-height: 1.5;
  overflow-x: auto;
  user-select: text;
  white-space: pre;
}

.empty-state {
  text-align: center;
  padding: 24px 10px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.5;
}


/* ==================== 6. 底部工业状态栏 ==================== */
.app-statusbar {
  height: 24px;
  background: #151518;
  border-top: 1px solid var(--border-main);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
  flex-shrink: 0;
  z-index: 30;
}

.status-info {
  font-family: Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 10.5px;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: var(--radius-xs);
  transition: color 0.1s, background 0.1s;
}

.status-link:hover {
  color: var(--text-title);
  background: var(--bg-panel-hover);
}

.status-sep {
  color: var(--text-dim);
}

/* ==================== 7. 画布外部文件拖放蒙层 & 轻提示 ==================== */
.canvas-drop-overlay {
  position: absolute;
  inset: 14px;
  background: rgba(15, 15, 18, 0.84);
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius-md);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  pointer-events: none;
}

.canvas-drop-overlay.active {
  display: flex;
}

.canvas-drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 28px;
  background: #1b1b20;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  color: var(--text-title);
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.canvas-drop-card svg {
  color: var(--accent);
}

.canvas-drop-title {
  font-size: 13px;
  font-weight: 600;
}

.canvas-drop-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.ve-toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translate(-50%, 8px);
  background: #1c1c22;
  color: var(--text-title);
  border: 1px solid #3c3c46;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 3500;
  transition: opacity 0.16s ease, transform 0.16s ease;
  white-space: nowrap;
}

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

.ve-toast-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.ve-toast.type-success .ve-toast-dot {
  background: var(--success);
}

.ve-toast.type-warn .ve-toast-dot {
  background: #d97706;
}

.ve-toast.type-error .ve-toast-dot {
  background: var(--danger);
}

/* ==================== 8. 文件导入弹窗与图片内联上传 ==================== */
.import-dropzone {
  border: 1.5px dashed #3d3d48;
  border-radius: var(--radius-md);
  background: #141418;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  outline: none;
}

.import-dropzone:hover,
.import-dropzone:focus,
.import-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(13, 139, 242, 0.06);
}

.import-mode-group {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.import-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.import-mode-option input {
  accent-color: var(--accent);
  cursor: pointer;
}

.import-mode-option:has(input:checked) {
  background: var(--bg-panel-hover);
  color: var(--text-title);
}

.import-format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.import-format-card {
  background: #17171b;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.import-format-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-title);
}

.import-format-ext {
  font-size: 10px;
  font-family: Consolas, monospace;
  color: #7cc4fa;
}

.import-format-desc {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.upload-inline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 26px;
  margin-bottom: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-xs);
  color: var(--text-title);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.upload-inline-btn:hover {
  background: var(--bg-panel-hover);
  border-color: var(--accent);
}

.local-image-note {
  font-size: 10px;
  color: #7cc4fa;
  background: rgba(13, 139, 242, 0.1);
  border: 1px solid rgba(13, 139, 242, 0.25);
  border-radius: var(--radius-xs);
  padding: 4px 6px;
  margin-bottom: 5px;
  line-height: 1.35;
}

/* ==================== 9. 使用指南选项卡与交互式导览 ==================== */
.guide-tabs {
  display: inline-flex;
  background: #111114;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.guide-tab {
  height: 22px;
  padding: 0 9px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.guide-tab:hover {
  color: var(--text-title);
}

.guide-tab.active {
  background: var(--bg-panel-hover);
  color: var(--text-title);
  font-weight: 500;
}

.guide-pane {
  display: none;
}

.guide-pane.active {
  display: block;
}

.guide-hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #17171b;
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
}

.guide-step-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-step-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  background: #17171b;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.guide-step-num {
  min-width: 32px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 139, 242, 0.14);
  border: 1px solid rgba(13, 139, 242, 0.35);
  border-radius: var(--radius-xs);
  color: #7cc4fa;
  font-size: 10px;
  font-weight: 700;
  font-family: Consolas, monospace;
  flex-shrink: 0;
  margin-top: 1px;
}

.guide-step-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-title);
  margin-bottom: 2px;
}

.guide-step-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: #17171b;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-main);
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  font-family: Consolas, monospace;
  color: var(--text-title);
  background: #25252c;
  border: 1px solid #3c3c46;
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
}

/* 交互式界面聚光灯导览 */
.tour-layer {
  position: fixed;
  inset: 0;
  z-index: 4500;
  display: none;
  pointer-events: auto;
}

.tour-layer.open {
  display: block;
}

.tour-ring {
  position: fixed;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  transition: left 0.2s ease, top 0.2s ease, width 0.2s ease, height 0.2s ease;
}

.tour-popover {
  position: fixed;
  width: 304px;
  background: #1d1d22;
  border: 1px solid #3f3f49;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
  color: var(--text-main);
  transition: left 0.2s ease, top 0.2s ease;
}

.tour-step-badge {
  font-size: 10px;
  font-family: Consolas, monospace;
  color: #7cc4fa;
  margin-bottom: 4px;
}

.tour-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-title);
  margin-bottom: 6px;
}

.tour-body {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 12px;
}

.tour-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
