/* ============ 流程图工坊 — 全局样式 ============ */
:root {
  /* B2B graphite / blue / orange 主题 */
  --bg: #F2F3F5;             /* workspace.bg */
  --panel-bg: #FFFFFF;       /* workspace.card */
  --border: #D6DADF;         /* border.line */
  --border-strong: #C2C8CF;
  --text: #1C2128;           /* text.strong */
  --text-2: #69707A;         /* text.weak */
  --text-3: #9AA0A8;
  --primary: #2C5F8A;        /* blue.600（替代原紫色） */
  --primary-hover: #244E73;
  --primary-soft: #E7EFF5;
  --accent: #E08A1E;         /* orange.500 */
  --accent-hover: #C9781A;
  --graphite: #2E3640;       /* graphite.700 */
  --danger: #E11D48;
  --danger-soft: #FFF1F2;
  --grid-dot: #DDE1E6;
  --shadow-sm: 0 1px 2px rgba(28,33,40,.05);
  --shadow-md: 0 4px 12px -2px rgba(28,33,40,.10), 0 2px 4px -2px rgba(28,33,40,.06);
  --shadow-lg: 0 20px 45px -12px rgba(28,33,40,.22);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ============ 顶栏 ============ */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 50px; padding: 0 12px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  z-index: 30; flex-shrink: 0;
  gap: 10px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 4px; }
.topbar-center { flex: 1; display: flex; justify-content: center; min-width: 0; }

.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 17px; letter-spacing: .2px;
  color: var(--graphite); padding: 0 8px 0 2px;
  user-select: none; white-space: nowrap;
}
.logo svg { color: var(--primary); }
.logo b { color: inherit; font-weight: inherit; }

#doc-title {
  border: 1px solid transparent; border-radius: 6px;
  padding: 5px 12px; font-size: 13.5px; font-weight: 600;
  text-align: center; background: transparent;
  max-width: 340px; width: 100%;
  transition: all .15s;
}
#doc-title:hover { background: var(--bg); }
#doc-title:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }

.tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 9px; border-radius: 6px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  transition: all .12s; white-space: nowrap;
}
.tb-btn:hover { background: var(--bg); color: var(--text); }
.tb-btn:disabled { opacity: .38; cursor: default; }
.tb-btn:disabled:hover { background: none; color: var(--text-2); }
.tb-btn.active { background: var(--primary-soft); color: var(--primary); }
.tb-btn.active:hover { background: var(--primary-soft); color: var(--primary); }
.tb-primary { background: var(--primary); color: #fff !important; padding: 6px 12px; }
.tb-primary:hover { background: var(--primary-hover); }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 5px; }

/* 排版方向切换 */
.dir-toggle { display: inline-flex; background: var(--bg); border-radius: 7px; padding: 2px; gap: 1px; }
.dir-toggle button { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 26px; border-radius: 5px; color: var(--text-3); transition: all .12s; }
.dir-toggle button:hover { color: var(--text-2); }
.dir-toggle button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }

/* 下拉菜单 */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 5px; min-width: 218px; z-index: 100;
  display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-menu button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; text-align: left; padding: 7px 10px; border-radius: 7px;
}
.dropdown-menu button:hover { background: var(--primary-soft); }
.dropdown-menu button b { font-size: 12.5px; font-weight: 600; }
.dropdown-menu button i { font-style: normal; font-size: 11px; color: var(--text-3); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ============ 主体 ============ */
#main { display: flex; flex: 1; min-height: 0; position: relative; }

/* ============ 左侧面板 ============ */
#side-panel {
  width: 336px; flex-shrink: 0;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: margin-left .2s ease;
}
#side-panel.collapsed { margin-left: -336px; }

.panel-tabs {
  display: flex; gap: 2px; padding: 8px 10px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-tab {
  flex: 1; padding: 8px 4px 9px; font-size: 13px; font-weight: 500;
  color: var(--text-3); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .12s;
}
.panel-tab:hover { color: var(--text-2); }
.panel-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

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

/* --- 自然语言 tab --- */
.segmented {
  display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px;
}
.segmented button {
  flex: 1; padding: 6px 8px; border-radius: 6px; font-size: 12.5px;
  color: var(--text-2); font-weight: 500; transition: all .12s;
}
.segmented button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

.nl-hint {
  font-size: 12px; line-height: 1.65; color: var(--text-2);
  background: var(--primary-soft); border-radius: 8px; padding: 9px 11px;
}
.nl-hint b { color: var(--primary); }

.dsl-help { margin-top: 6px; }
.dsl-help summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.dsl-help table { margin-top: 7px; border-collapse: collapse; width: 100%; }
.dsl-help td { padding: 3px 6px 3px 0; vertical-align: top; font-size: 11.5px; }
.dsl-help code { background: rgba(44,95,138,.1); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 10.5px; white-space: nowrap; }

#nl-input {
  width: 100%; min-height: 180px; resize: vertical;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; line-height: 1.7;
  transition: border-color .12s;
}
#nl-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.nl-actions { display: flex; gap: 8px; align-items: center; }
.nl-status { font-size: 12px; color: var(--text-3); min-height: 18px; line-height: 1.5; }
.nl-status.error { color: var(--danger); }
.nl-status.ok { color: #16A34A; }

/* --- 按钮体系 --- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: #fff;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  transition: all .12s;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; border-radius: 7px;
  border: 1px solid var(--border); background: #fff;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  transition: all .12s;
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); background: var(--bg); }
.btn-danger {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; border-radius: 7px;
  border: 1px solid #FECDD3; background: var(--danger-soft);
  font-size: 12.5px; font-weight: 500; color: var(--danger);
  transition: all .12s;
}
.btn-danger:hover { background: #FFE4E6; border-color: #FDA4AF; }
.btn-sm { padding: 4.5px 9px; font-size: 12px; }
.btn-icon { display: inline-flex; padding: 5px; border-radius: 6px; color: var(--text-3); }
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* --- 代码 tab --- */
.code-toolbar { display: flex; align-items: center; justify-content: space-between; }
.code-toolbar-right { display: flex; gap: 6px; }
.code-status { font-size: 11.5px; color: var(--text-3); }
.code-status.dirty { color: #D97706; }
.code-status.error { color: var(--danger); }
.code-wrap { flex: 1; display: flex; min-height: 260px; }
#code-input {
  flex: 1; width: 100%; resize: none;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.75;
  background: #FBFCFE; color: #1E293B;
  white-space: pre; overflow: auto;
  tab-size: 4;
}
#code-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.code-error {
  font-size: 12px; color: var(--danger); background: var(--danger-soft);
  border-radius: 7px; padding: 8px 10px; line-height: 1.55;
  font-family: var(--mono);
  white-space: pre-wrap;
}
.code-note { font-size: 11.5px; color: var(--text-3); line-height: 1.7; }
.code-note code { background: var(--bg); border: 1px solid var(--border); padding: 0 4px; border-radius: 4px; font-family: var(--mono); font-size: 10.5px; }

/* --- 模板 tab --- */
.tpl-section-title {
  font-size: 12px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
  display: flex; align-items: center; justify-content: space-between;
}
.tpl-mine { margin-top: 10px; }
.tpl-list { display: flex; flex-direction: column; gap: 8px; }
.tpl-card {
  display: flex; gap: 11px; align-items: center;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; background: #fff;
  transition: all .13s; text-align: left; width: 100%;
  position: relative;
}
.tpl-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tpl-thumb {
  width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.tpl-info { min-width: 0; flex: 1; }
.tpl-info b { display: block; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.tpl-info i { display: block; font-style: normal; font-size: 11.5px; color: var(--text-3); line-height: 1.45;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tpl-del {
  position: absolute; top: 7px; right: 7px;
  padding: 3px; border-radius: 5px; color: var(--text-3);
  opacity: 0; transition: all .12s;
}
.tpl-card:hover .tpl-del { opacity: 1; }
.tpl-del:hover { background: var(--danger-soft); color: var(--danger); }
.tpl-empty { font-size: 12px; color: var(--text-3); text-align: center; padding: 14px 0; }

/* ============ 画布 ============ */
#canvas-area { flex: 1; position: relative; min-width: 0; background: var(--bg); }
#canvas { width: 100%; height: 100%; display: block; outline: none; cursor: default; touch-action: none; }
#canvas.panning { cursor: grabbing; }
#canvas.connecting { cursor: crosshair; }

.canvas-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  color: var(--text-3); pointer-events: none; text-align: center;
  font-size: 13.5px; line-height: 1.8;
}

/* 节点 */
.fc-node { cursor: grab; }
.fc-node.dragging { cursor: grabbing; }
.fc-node .node-shape {
  stroke-width: 1.5;
  transition: filter .12s;
}
.fc-node:hover .node-shape { filter: brightness(.978) saturate(1.15); }
.fc-node.selected .node-shape {
  stroke-width: 2.4;
  filter: drop-shadow(0 0 0 rgba(0,0,0,0)) drop-shadow(0 2px 8px rgba(44,95,138,.28));
}
.fc-node.connect-target .node-shape { stroke: var(--primary); stroke-width: 2.6; stroke-dasharray: 5 4; }
.fc-node.connect-source .node-shape { stroke: var(--primary); stroke-width: 2.8; filter: drop-shadow(0 2px 8px rgba(44,95,138,.32)); }
.fc-node text { user-select: none; pointer-events: none; }

/* 锚点 */
.anchor {
  fill: #fff; stroke: var(--primary); stroke-width: 1.6;
  cursor: crosshair; opacity: 0;
  transition: opacity .12s;
}
.fc-node:hover .anchor, .anchor.visible { opacity: 1; }
.anchor:hover { fill: var(--primary-soft); r: 6; }

/* 边 */
.fc-edge { cursor: pointer; }
.fc-edge .edge-hit { stroke: transparent; stroke-width: 14; fill: none; }
.fc-edge .edge-line { fill: none; stroke: #64748B; stroke-width: 1.6; transition: stroke .12s; }
.fc-edge.dotted .edge-line { stroke-dasharray: 6 4.5; }
.fc-edge:hover .edge-line { stroke: #334155; stroke-width: 2; }
.fc-edge.selected .edge-line { stroke: var(--primary); stroke-width: 2.2; }
.edge-label-bg { fill: #fff; stroke: var(--border); stroke-width: 1; rx: 5; }
.fc-edge.selected .edge-label-bg { stroke: var(--primary); }
.edge-label-text { font-size: 11.5px; fill: #475569; user-select: none; }
.fc-edge.selected .edge-label-text { fill: var(--primary); font-weight: 600; }

/* 临时连线 */
.temp-edge { stroke: var(--primary); stroke-width: 2; stroke-dasharray: 6 4; fill: none; pointer-events: none; }

/* 图例 */
.legend {
  position: absolute; left: 14px; bottom: 14px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 5px;
  max-width: 240px; z-index: 5;
}
.legend:empty { display: none; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-2); }
.legend-swatch { width: 13px; height: 13px; border-radius: 4px; flex-shrink: 0; border: 1.5px solid; }

/* 缩放控件 */
#zoom-ctrl {
  position: absolute; right: 14px; bottom: 14px;
  display: flex; align-items: center; gap: 2px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 3px; box-shadow: var(--shadow-sm); z-index: 5;
}
#zoom-ctrl button {
  width: 26px; height: 26px; border-radius: 6px;
  font-size: 15px; color: var(--text-2); line-height: 1;
}
#zoom-ctrl button:hover { background: var(--bg); color: var(--text); }
#zoom-pct { font-size: 11.5px; color: var(--text-2); min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }

/* 行内编辑器 */
#inline-editor {
  position: absolute; z-index: 20;
  border: 2px solid var(--primary); border-radius: 8px;
  padding: 6px 9px; font-size: 13px; line-height: 1.5; text-align: center;
  background: #fff; box-shadow: var(--shadow-md);
  resize: none; overflow: hidden;
}
#inline-editor:focus { outline: none; }

/* ============ 属性面板 ============ */
#prop-panel {
  position: absolute; right: 14px; top: 14px;
  width: 252px; background: #fff;
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); z-index: 15;
  max-height: calc(100% - 28px);
  display: flex; flex-direction: column;
}
.prop-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px 9px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.prop-body { padding: 12px 14px 14px; overflow-y: auto; }
.prop-label {
  display: block; font-size: 11.5px; font-weight: 600; color: var(--text-3);
  margin: 11px 0 5px;
}
.prop-body > div > .prop-label:first-child, #prop-node .prop-label:first-child, #prop-edge .prop-label:first-child { margin-top: 0; }
#prop-node-label, #prop-edge-label, .modal-body input, .modal-body select {
  width: 100%; border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 10px; font-size: 13px; line-height: 1.5; resize: vertical;
  transition: border-color .12s;
}
#prop-node-label:focus, #prop-edge-label:focus, .modal-body input:focus, .modal-body select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}

.shape-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.shape-grid button {
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 4px;
  color: var(--text-2); transition: all .12s;
}
.shape-grid button:hover { border-color: var(--border-strong); background: var(--bg); }
.shape-grid button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.class-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 7px; }
.class-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 12.5px; transition: all .12s; width: 100%; text-align: left;
}
.class-item:hover { border-color: var(--border-strong); background: var(--bg); }
.class-item.active { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.class-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid; flex-shrink: 0; }
.class-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-rename { flex-shrink: 0; display: inline-flex; padding: 3px; border-radius: 5px; color: var(--text-3); opacity: 0; transition: all .12s; }
.class-item:hover .class-rename { opacity: 1; }
.class-rename:hover { background: #fff; color: var(--primary); }
.class-rename-input { flex: 1; min-width: 0; border: 1.5px solid var(--primary); border-radius: 5px; padding: 2px 7px; font-size: 12.5px; box-shadow: 0 0 0 3px var(--primary-soft); }
.class-rename-input:focus { outline: none; }
.class-swatch.clickable { cursor: pointer; transition: transform .1s; }
.class-swatch.clickable:hover { transform: scale(1.18); }
.recolor-pop { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; padding: 4px 2px 8px; margin-top: -2px; }
.recolor-swatch { height: 24px; border-radius: 6px; border: 2px solid; transition: transform .1s; }
.recolor-swatch:hover { transform: scale(1.12); }
.recolor-swatch.active { box-shadow: 0 0 0 2px var(--primary-soft), 0 0 0 3.5px var(--primary); }

.prop-actions { display: flex; gap: 7px; margin-top: 14px; }
.prop-actions button { flex: 1; justify-content: center; }

/* 边样式 segmented */
#prop-edge-style button { font-size: 12px; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.42);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 14px; width: 430px; max-width: calc(100vw - 40px);
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease;
}
.modal-sm { width: 360px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px 12px; font-weight: 700; font-size: 14.5px;
}
.modal-body { padding: 2px 18px 8px; }
.modal-body .prop-label { margin-top: 12px; }
.modal-body .prop-label:first-child { margin-top: 0; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px 16px;
}
.settings-note {
  margin-top: 12px; font-size: 11.5px; line-height: 1.7; color: var(--text-3);
  background: var(--bg); border-radius: 8px; padding: 9px 11px;
}
.settings-note code { font-family: var(--mono); font-size: 10px; background: #fff; border: 1px solid var(--border); padding: 0 3px; border-radius: 3px; }
.settings-sub { margin-top: 5px; }
.settings-sub a { font-size: 11.5px; color: var(--primary); text-decoration: none; }
.settings-sub a:hover { text-decoration: underline; }
.label-hint { font-weight: 400; color: var(--text-3); font-size: 10.5px; }

.palette-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-top: 2px; }
.palette-grid button {
  height: 34px; border-radius: 8px; border: 2px solid;
  transition: transform .1s; position: relative;
}
.palette-grid button:hover { transform: scale(1.08); }
.palette-grid button.active::after {
  content: ""; position: absolute; inset: -5px;
  border: 2px solid var(--primary); border-radius: 11px;
}

/* ============ Toast ============ */
#toast-wrap {
  position: fixed; top: 62px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 500;
  pointer-events: none;
}
.toast {
  background: #1E293B; color: #F1F5F9;
  padding: 9px 16px; border-radius: 9px;
  font-size: 12.5px; box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
  max-width: 420px; line-height: 1.5;
}
.toast.error { background: #9F1239; }
.toast.success { background: #166534; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transition: opacity .3s; }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; background-clip: content-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 移动端自适应 ============ */
#mobile-mask { display: none; }

@media (max-width: 820px) {
  /* --- 顶栏精简：图标化 + 可横向滑动 --- */
  #topbar { height: 48px; padding: 0 6px; gap: 2px; }
  .topbar-left { flex-shrink: 0; }
  .topbar-center { display: none; }                 /* 标题在移动端隐藏 */
  .logo { font-size: 14.5px; gap: 6px; padding: 0 2px; }
  .logo svg { width: 20px; height: 20px; }
  .topbar-right {
    gap: 2px; flex-wrap: nowrap;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .topbar-right::-webkit-scrollbar { display: none; }
  .tb-btn { padding: 7px; flex-shrink: 0; }
  .tb-btn span { display: none; }                   /* 按钮只留图标 */
  .tb-primary { padding: 7px 9px; }
  .tb-primary span { display: inline; }             /* 导出保留文字 */
  .tb-sep { margin: 0 2px; flex-shrink: 0; }
  .dir-toggle { flex-shrink: 0; }
  .dropdown-menu { position: fixed; right: 8px; left: auto; top: 52px; }

  /* --- 左面板 → 滑出抽屉 --- */
  #side-panel {
    position: fixed; top: 48px; left: 0; bottom: 0; z-index: 45;
    width: min(87vw, 340px);
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 26px rgba(28,33,40,.20);
    margin-left: 0 !important;
  }
  #side-panel.mobile-open { transform: translateX(0); }

  #mobile-mask {
    display: block; position: fixed; inset: 48px 0 0 0; z-index: 44;
    background: rgba(28,33,40,.34);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  #mobile-mask.show { opacity: 1; pointer-events: auto; }

  /* --- 属性面板 → 底部弹层 --- */
  #prop-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; max-width: none; max-height: 58vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(28,33,40,.22);
    z-index: 46;
  }
  .prop-header { padding: 13px 16px 10px; }

  /* --- 画布控件避让 --- */
  #zoom-ctrl { right: 10px; bottom: 10px; }
  .legend { left: 10px; bottom: 10px; max-width: 44vw; padding: 7px 9px; }
  .legend-item { font-size: 11px; }

  /* --- 弹窗/空状态 --- */
  .modal { width: calc(100vw - 24px); }
  .modal-sm { width: calc(100vw - 48px); }
  .canvas-empty p { font-size: 12.5px; padding: 0 26px; }
}

@media (max-width: 480px) {
  .logo { font-size: 13.5px; }
  .topbar-right { gap: 1px; }
  .tb-btn { padding: 6px; }
  .tb-primary span { display: none; }               /* 超窄屏导出也只留图标 */
  #prop-panel { max-height: 66vh; }
  .legend { max-width: 38vw; }
}
