/* ===== PID Designer v2.0 ===== */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6eb;
  --border-strong: #d4d8de;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eef4ff;
  --danger: #c0392b;
  --warn: #d97706;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg);
  user-select: none; -webkit-font-smoothing: antialiased;
}
#app { display: flex; flex-direction: column; }

/* ---------- 图纸与绘图工具 ---------- */
#documentBar {
  display: flex; align-items: center; gap: 24px; min-height: 64px; padding: 10px 18px;
  background: #12283d; color: #fff; flex-shrink: 0;
}
.app-brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 650; white-space: nowrap; }
.brand-icon { display: grid; place-items: center; width: 34px; height: 34px; background: #2583dc; border: 1px solid #68b0f3; border-radius: 9px; font-size: 23px; font-weight: 750; }
.app-brand small { display: block; color: #aac1d6; font-size: 10px; font-weight: 400; margin-top: 2px; letter-spacing: .06em; }
.document-title { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
#docName { width: 260px; max-width: 100%; padding: 7px 9px; color: #fff; background: transparent; border: 1px solid transparent; border-radius: 6px; font-size: 14px; font-weight: 500; font-family: inherit; min-width: 80px; text-overflow: ellipsis; }
#docName:hover, #docName:focus { background: #203c55; border-color: #506b80; }
#dirtyMark.dirty { color: #ffd386; font-size: 11px; white-space: nowrap; }
#toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.tb-group { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 3px; flex: 0 0 auto; }
.tb-spacer { flex: 1 1 auto; min-width: 0; }
#toolbar button, #documentBar button {
  padding: 6px 9px; min-height: 30px; border: 1px solid transparent; border-radius: 5px;
  background: transparent; font-size: 12px; color: var(--text); cursor: pointer;
  white-space: nowrap; line-height: 1.3; font-family: inherit;
}
#toolbar button:hover { background: #eef3f8; border-color: #d4dfe9; }
#toolbar button:active { background: #e1eaf4; }
#toolbar button.icon { font-size: 17px; padding: 3px 7px; min-width: 30px; }
#toolbar button.active { background: #e9f2fc; color: #1764a9; border-color: #cbdff1; }
#toolbar button.active:hover { background: #dcecff; }
button:disabled, #toolbar select:disabled { opacity: .4; cursor: default; }
#toolbar select { padding: 5px 5px; min-height: 30px; max-width: 150px; border: 1px solid var(--border); border-radius: 5px; background: #fff; font-size: 12px; color: var(--text); cursor: pointer; font-family: inherit; }
.pipe-mode-tools { gap: 5px; }
.pipe-mode-tools label { display: flex; align-items: center; gap: 5px; color: #597086; font-size: 11px; white-space: nowrap; }
#toolbar #selPipeMode { width: 98px; border-color: #cbdbe9; background: #f7fbff; color: #295b87; }
#toolbar #btnPipeAutoAlign { display: inline-flex; align-items: center; gap: 4px; color: #295b87; border-color: #dbe6ef; padding-left: 7px; padding-right: 7px; }
#toolbar #btnPipeAutoAlign:disabled { color: var(--muted); }
#toolbar #btnAutoLayout { display: flex; align-items: center; gap: 6px; border-color: #dbe6ef; }
.switch-track { width: 23px; height: 13px; border-radius: 7px; background: #b6c4d0; position: relative; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 9px; height: 9px; border-radius: 50%; background: #fff; }
[aria-checked="true"] .switch-track { background: #267cce; }
[aria-checked="true"] .switch-track::after { left: 12px; }
#documentBar button { color: #e1edf7; border-color: #466076; padding: 7px 14px; }
#documentBar button:hover { background: #2a435b; border-color: #7791a8; }
#documentBar button.primary { background: #267cce; color: white; border-color: #3f90da; }
#documentBar button.primary:hover { background: #358fdf; }
#zoomLabel { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 39px; text-align: center; }
#toolbar .zoom-tools { border: 1px solid var(--border); border-radius: 6px; gap: 1px; }
.hidden, [hidden] { display: none !important; }
button, input, select, textarea { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid #2583dc; outline-offset: 2px; }
#canvas:focus-visible { outline-offset: -3px; }
#body { flex: 1; display: flex; min-height: 0; position: relative; }

/* ---------- 左侧符号库 ---------- */
#palette { width: 230px; flex: 0 0 auto; background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; padding: 0 10px 12px; scrollbar-width: thin; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; font-weight: 600; color: #273e52; min-height: 42px; background: var(--panel); z-index: 2; }
.panel-count { color: #7e91a3; font-size: 11px; font-weight: 400; white-space: nowrap; }
.palette-head { position: sticky; top: 0; z-index: 3; padding-bottom: 9px; background: var(--panel); border-bottom: 1px solid var(--border); }
.palette-search { display: flex; align-items: center; position: relative; }
#symSearch { width: 100%; padding: 8px 26px 8px 9px; min-width: 0; border: 1px solid #d4dfe9; border-radius: 6px; background: #f7fafc; font-size: 12px; }
#symSearch::-webkit-search-cancel-button { display: none; }
#clearSymSearch { position: absolute; right: 4px; width: 24px; height: 26px; border: 0; background: transparent; color: #5c7083; cursor: pointer; font-size: 18px; }
#symCategory { width: 100%; padding: 6px 8px; border: 1px solid #dce4ec; border-radius: 6px; background: #fff; color: #4a6074; font-size: 12px; margin-top: 7px; }
.palette-guide { margin-top: 8px; font-size: 10px; color: #7c8c9a; }
.palette-library-actions { display: flex; gap: 5px; margin-top: 8px; }
.palette-library-actions button { flex: 1; border: 1px solid #dce4ec; border-radius: 5px; background: #fff; color: #526b81; padding: 5px 3px; font-size: 11px; cursor: pointer; }
.palette-library-actions button:hover { border-color: #77aee0; background: #f1f7fe; }
.palette-library-actions [aria-pressed="true"] { color: #a94646; border-color: #e6b4b4; background: #fff4f4; }
.palette-delete-mode .sym-item { position: relative; cursor: pointer; border-style: dashed; border-color: #dfbcbc; }
.palette-delete-mode .sym-item::after { content: '−'; position: absolute; top: 4px; right: 5px; width: 17px; height: 17px; line-height: 16px; text-align: center; color: #b35151; background: #fff1f1; border-radius: 50%; }
.palette-delete-mode .palette-guide { color: #a56262; line-height: 1.6; }
.palette-section { margin-top: 9px; }
.palette-cat { width: 100%; display: flex; align-items: center; gap: 6px; font-size: 11px; color: #5c7184; padding: 6px 2px; border: 0; background: transparent; text-align: left; font-weight: 650; cursor: pointer; }
.palette-cat::before { content: '⌄'; font-size: 14px; width: 12px; line-height: 1; }
.palette-cat[aria-expanded=false]::before { content: '›'; }
.palette-cat .cat-count { margin-left: auto; font-size: 10px; font-weight: 400; color: #8b9baa; }
.sym-item { display: flex; align-items: center; gap: 10px; padding: 5px 7px; min-height: 45px; border: 1px solid #e7edf3; border-radius: 6px; margin-bottom: 4px; cursor: grab; background: #fff; transition: border-color .12s, background .12s; }
.sym-item:hover, .sym-item:focus-visible { border-color: #77aee0; background: #f0f7ff; }
.sym-item:active { cursor: grabbing; }
.sym-item svg { width: 34px; height: 34px; flex: 0 0 auto; pointer-events: none; }
.sym-item .sym-label { font-size: 11px; line-height: 1.5; color: #3d5265; pointer-events: none; }
.palette-empty { padding: 28px 8px; text-align: center; color: #8a98a7; font-size: 12px; line-height: 1.8; }
.palette-empty strong { display: block; color: #50677b; margin-bottom: 6px; font-weight: 500; }

/* 预览卡片与列表共用符号节点，切换布局保留搜索和拖放状态。 */
.panel-title-group { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.panel-title-group .panel-count { font-size: 10px; }
.palette-view-switch { display: flex; padding: 2px; gap: 1px; border: 1px solid #e3eaf1; background: #f5f8fb; border-radius: 5px; }
.palette-view-switch button { display: grid; place-items: center; width: 23px; height: 23px; padding: 3px; border: 0; border-radius: 3px; background: transparent; color: #8b9cac; cursor: pointer; }
.palette-view-switch button:hover { color: #2b74b4; }
.palette-view-switch button[aria-pressed=true] { color: #246fae; background: #fff; box-shadow: 0 1px 3px #1c3c561c; }
.palette-view-switch svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.search-icon { position: absolute; left: 9px; width: 14px; height: 14px; fill: none; stroke: #8b9cac; stroke-width: 1.6; pointer-events: none; }
#symSearch { padding-left: 29px; }
#palette[data-view=grid] .palette-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
#palette[data-view=grid] .sym-item { flex-direction: column; justify-content: flex-start; gap: 5px; min-width: 0; min-height: 99px; padding: 9px 5px 7px; margin-bottom: 0; background: linear-gradient(180deg, #fff 60%, #fafcff); border-radius: 8px; }
#palette[data-view=grid] .sym-item svg { width: 49px; height: 49px; }
#palette[data-view=grid] .sym-label { width: 100%; text-align: center; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
#palette[data-view=grid] .sym-item:hover { background: #f0f7ff; box-shadow: 0 2px 7px #236ebd10; }
#palette .palette-section[hidden], #palette .palette-items[hidden], #palette .sym-item[hidden] { display: none !important; }
#documentBar button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.action-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- 画布 ---------- */
#canvasWrap { flex: 1; position: relative; background: #ffffff; min-width: 0; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: default; display: block; }
#canvas.panning { cursor: grabbing; }
#canvas.connecting { cursor: crosshair; }
#canvas.textmode { cursor: text; }
#canvas.picking { cursor: pointer; }
#hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); max-width: calc(100% - 24px); width: max-content; font-size: 10px; color: #698093; line-height: 1.5; background: rgba(255,255,255,.95); padding: 6px 12px; border-radius: 6px; pointer-events: none; border: 1px solid #d9e3eb; box-shadow: 0 2px 7px #1c3c5610; }
#canvas .port { cursor: crosshair; }
#canvas [data-sym], #canvas [data-wp], #canvas.dragging { cursor: move; }
#canvas .pipe-route-hit, #canvas .pipe-segment-hit { cursor: grab; }
#canvas .pipe-segment-hit[data-axis="y"] { cursor: ns-resize; }
#canvas .pipe-segment-hit[data-axis="x"] { cursor: ew-resize; }
#canvas.pipe-drag-y, #canvas.pipe-drag-y * { cursor: ns-resize !important; }
#canvas.pipe-drag-x, #canvas.pipe-drag-x * { cursor: ew-resize !important; }
#canvas.pipe-drag-free, #canvas.pipe-drag-free * { cursor: grabbing !important; }
#statusBar { display: flex; justify-content: space-between; align-items: center; gap: 14px; min-height: 26px; padding: 4px 14px; border-top: 1px solid #dbe3eb; background: #f8fafc; color: #748797; font-size: 10px; flex-shrink: 0; }
#drawingStatus, #selectionStatus { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 右侧属性 ---------- */
#props { width: 264px; flex: 0 0 auto; background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; padding: 0 14px 16px; scrollbar-width: thin; }
#props > .panel-head { position: sticky; top: 0; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
#palette.panel-collapsed, #props.panel-collapsed { display: none; }
/* 概览使用轻量卡片，选中对象后呈现完整属性表单。 */
.overview-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 3px 0 15px; }
.overview-metric { display: flex; flex-direction: column; gap: 4px; padding: 12px 3px 10px; text-align: center; border: 1px solid #e4ecf3; border-radius: 8px; background: #f8fafc; }
.overview-metric b { font-size: 24px; line-height: 1.1; font-weight: 600; font-variant-numeric: tabular-nums; color: #264a68; }
.overview-metric span { font-size: 10px; color: #7a8e9e; white-space: nowrap; }
.sheet-card { padding: 12px; border: 1px solid #e3eaf1; border-radius: 8px; margin-bottom: 18px; }
.sheet-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; font-size: 12px; font-weight: 600; color: #3d566c; }
.sheet-badge { font-size: 10px; font-weight: 500; color: #487692; background: #edf4f8; border-radius: 4px; padding: 3px 6px; }
.sheet-details > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 9px 0; font-size: 11px; }
.sheet-details dt { color: #81919f; flex-shrink: 0; }
.sheet-details dd { color: #445d71; min-width: 0; text-align: right; overflow-wrap: anywhere; }
.sheet-card .btn-plain { display: flex; justify-content: space-between; align-items: center; margin-top: 13px; padding: 7px 9px; font-size: 11px; border-color: #e1e8ef; background: #fafcfe; }
.selection-guide { display: flex; gap: 9px; padding: 12px 10px; border: 1px dashed #dbe6ef; border-radius: 8px; background: #f6faff; }
.selection-guide > svg { width: 23px; height: 23px; flex: 0 0 auto; fill: #e0efff; stroke: #6297c0; stroke-width: 1.5; stroke-linejoin: round; }
.selection-guide strong { display: block; color: #466987; font-size: 11px; font-weight: 550; margin-bottom: 4px; }
.selection-guide p { color: #8296a6; font-size: 10px; line-height: 1.7; }
.quick-guide { padding: 19px 2px 3px; }
.quick-guide h3 { font-size: 11px; color: #8394a2; font-weight: 500; margin-bottom: 12px; }
.quick-guide > div { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 13px; }
.guide-number { width: 18px; height: 18px; display: grid; place-items: center; flex-shrink: 0; border: 1px solid #e0e8ef; border-radius: 5px; background: #f8fafc; color: #89a0b3; font-size: 10px; }
.quick-guide p strong { display: block; font-size: 11px; color: #5c7488; font-weight: 500; margin-bottom: 3px; }
.quick-guide p span { font-size: 10px; line-height: 1.6; color: #92a1ae; }
#props .overview-autotag { padding: 8px; font-size: 11px; color: #5a7892; background: #fff; border-color: #e0e8ef; }
.props-empty { color: #9aa2ae; font-size: 12px; padding: 10px 0; line-height: 1.7; }
.prop-title {
  font-size: 12px; color: #4b5563; margin: 12px 0 8px; font-weight: 600;
  border-left: 3px solid var(--accent); padding-left: 7px;
}
.prop-title:first-child { margin-top: 4px; }
.prop-row { margin-bottom: 9px; }
.prop-row > label { display: block; font-size: 12px; color: #4b5563; margin-bottom: 3px; }
.prop-row .prop-check { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.prop-row input[type=text], .prop-row input[type=number], .prop-row textarea, .prop-row select {
  width: 100%; padding: 5px 7px; border: 1px solid var(--border-strong);
  border-radius: 6px; font-size: 13px; font-family: inherit; color: var(--text); background: #fff;
}
.prop-row input:focus, .prop-row textarea:focus, .prop-row select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}
.prop-row textarea { resize: vertical; min-height: 50px; line-height: 1.5; }
.prop-inline { display: flex; align-items: center; gap: 8px; }
.prop-inline input[type=color] {
  width: 42px; height: 30px; border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 2px; background: #fff; cursor: pointer;
}
.prop-inline span { font-size: 12px; color: var(--muted); }
.prop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prop-note { font-size: 11px; color: #9aa2ae; line-height: 1.6; margin-top: 6px; }
.prop-stat { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.prop-stat b { font-weight: 600; }

.btn-danger {
  width: 100%; padding: 6px 0; border: 1px solid #f3c1c1; border-radius: 6px;
  background: #fdf2f2; color: var(--danger); font-size: 13px; cursor: pointer; font-family: inherit;
}
.btn-danger:hover { background: #fbe3e3; }
.btn-plain {
  width: 100%; padding: 6px 0; border: 1px solid var(--border-strong); border-radius: 6px;
  background: #fafbfc; font-size: 13px; cursor: pointer; font-family: inherit; color: var(--text);
}
.btn-plain:hover { background: #eef1f5; }
.btn-mini {
  padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 5px;
  background: #fafbfc; font-size: 12px; cursor: pointer; font-family: inherit; color: var(--text);
}
.btn-mini:hover { background: #eef1f5; border-color: #b9c0ca; }
.btn-mini.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%);
  background: rgba(30,34,40,.93); color: #fff; font-size: 13px;
  padding: 8px 18px; border-radius: 20px; z-index: 400;
  opacity: 0; transition: opacity .22s; pointer-events: none; max-width: 70vw;
  text-align: center; line-height: 1.5;
}
#toast.show { opacity: 1; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.34);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
.modal {
  background: #fff; border-radius: 12px; width: 620px; max-width: 92vw;
  max-height: 84vh; display: flex; flex-direction: column;
  box-shadow: 0 18px 48px rgba(0,0,0,.24); overflow: hidden;
}
.modal.narrow { width: 460px; }
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center;
}
.modal-head button {
  border: none; background: none; font-size: 18px; color: var(--muted); cursor: pointer;
  line-height: 1; padding: 0 4px;
}
.modal-body { padding: 16px 18px; overflow: auto; font-size: 13px; line-height: 1.7; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal-foot button {
  padding: 6px 16px; border: 1px solid var(--border-strong); border-radius: 6px;
  background: #fafbfc; font-size: 13px; cursor: pointer; font-family: inherit; color: var(--text);
}
.modal-foot button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.modal-foot button.primary:hover { background: #1d4fd8; }
.modal-foot button:hover { background: #eef1f5; }
.modal pre {
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px;
  line-height: 1.75; white-space: pre; overflow-x: auto; color: #374151;
  background: #f8f9fb; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border);
}
.modal table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.modal table th, .modal table td {
  border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top;
}
.modal table th { background: #f6f8fa; font-weight: 600; color: #374151; }
.modal table td.num { text-align: right; white-space: nowrap; }

/* ---------- 自定义图片符号 ---------- */
.modal.library-editor { width: 850px; max-width: 95vw; max-height: 92vh; }
.library-form-grid { display: grid; grid-template-columns: 1.4fr 1fr .7fr; gap: 5px 12px; }
.library-file-row { grid-column: 1 / -1; }
.library-file-row input { max-width: 100%; font-size: 12px; }
.library-preview { min-height: 150px; padding: 17px; border: 1px dashed #cad9e5; background: #f5f8fb; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin: 8px 0 14px; }
#libImageEmpty { color: #8295a7; font-size: 12px; }
#libImageStage { position: relative; display: inline-block; min-width: 0; cursor: crosshair; }
#libImagePreview { display: block; width: auto; height: auto; max-width: 100%; max-height: 300px; user-select: none; }
#libPortMarkers { position: absolute; inset: 0; pointer-events: none; }
.library-port-marker { position: absolute; transform: translate(-50%, -50%); border: 2px solid #fff; border-radius: 50%; min-width: 21px; height: 21px; line-height: 17px; text-align: center; background: #267cce; color: #fff; font-size: 10px; box-shadow: 0 0 0 1px #267cce; }
.library-ports-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; }
.library-ports-head strong span { color: #8091a0; font-weight: 400; margin-left: 7px; }
.library-ports-scroll { overflow-x: auto; margin: 8px 0; border: 1px solid #e1e7ee; border-radius: 6px; }
.library-ports-table { min-width: 630px; }
.library-ports-table th:nth-child(1) { width: 135px; }
.library-ports-table th:nth-child(2), .library-ports-table th:nth-child(3) { width: 72px; }
.library-ports-table th:nth-child(4) { width: 86px; }
.library-ports-table th:last-child { width: 55px; }
.library-ports-table input, .library-ports-table select { width: 100%; min-width: 0; padding: 5px 4px; border: 1px solid #d9e2eb; border-radius: 4px; font-size: 11px; }
.library-ports-table .btn-mini { font-size: 11px; padding: 4px; }
.dialog-error { margin: 10px 0 0; padding: 9px 11px; color: #a23a3a; background: #fff1f1; border: 1px solid #f0d0d0; border-radius: 6px; font-size: 12px; overflow-wrap: anywhere; }
.library-hidden-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #e6edf3; }
.library-hidden-row > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.library-hidden-row strong { font-size: 13px; font-weight: 500; color: #3b5368; }
.library-hidden-row span { font-size: 11px; color: #8192a2; }
@media (max-width: 540px) { .library-form-grid { grid-template-columns: 1fr 1fr; } .library-form-grid .prop-row:nth-child(2) { grid-column: 1 / -1; } .library-editor .modal-body { padding: 12px; } }

/* ---------- 启动使用说明 ---------- */
.modal.startup-guide { width: 690px; max-height: 90vh; }
.startup-guide .modal-head { color: #526477; font-size: 13px; }
.startup-guide .modal-body { padding: 22px 26px 18px; }
.guide-eyebrow { color: #3979ad; font-size: 10px; font-weight: 700; letter-spacing: 1.6px; }
.guide-intro h1 { margin: 4px 0 5px; font-size: 24px; line-height: 1.35; color: #20364b; }
.guide-intro p { margin: 0; color: var(--muted); }
.guide-steps { display: grid; gap: 15px; list-style: none; margin: 22px 0 18px; padding: 0; }
.guide-steps li { display: flex; gap: 12px; align-items: flex-start; }
.guide-step-number { display: grid; place-items: center; flex: 0 0 29px; height: 29px; border-radius: 7px; background: #eef5fb; color: #3274aa; font-size: 11px; font-weight: 700; }
.guide-steps h2 { font-size: 14px; line-height: 1.5; margin: 0 0 3px; color: #294259; }
.guide-steps p { margin: 0; color: #526477; font-size: 12px; line-height: 1.7; }
.guide-steps b { font-weight: 600; color: #355e80; }
.guide-shortcuts { display: flex; flex-wrap: wrap; gap: 7px 15px; padding: 11px 13px; background: #f5f8fb; border-radius: 7px; color: #536e85; font-size: 11px; }
.guide-details { margin-top: 14px; color: #607b92; font-size: 12px; }
.guide-details summary { cursor: pointer; width: fit-content; }
.guide-details pre { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 0; font-size: 11px; }
.startup-guide .modal-foot { padding: 14px 26px; }
.startup-guide .modal-foot button { min-height: 36px; }
@media (max-width: 480px) {
  .startup-guide .modal-body { padding: 16px; }
  .guide-intro h1 { font-size: 21px; }
  .guide-steps { gap: 13px; margin-top: 18px; }
  .startup-guide .modal-foot { padding: 12px 16px; }
}

/* ---------- 导出下拉 ---------- */
#exportMenu {
  position: fixed; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.16);
  padding: 5px; z-index: 350; min-width: 208px;
}
#exportMenu button {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  border: none; background: none; font-size: 13px; border-radius: 6px;
  cursor: pointer; color: var(--text); font-family: inherit;
}
#exportMenu button:hover { background: var(--accent-soft); }
#exportMenu .sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* ---------- 窄窗口仍保留全部工具 ---------- */
@media (max-width: 1100px) {
  #documentBar { gap: 14px; padding: 9px 12px; }
  #docName { width: 220px; }
  #toolbar { gap: 4px; padding: 6px 8px; }
  #toolbar .tb-sep { margin: 0 1px; }
  #palette { width: 208px; }
  #props { width: 242px; padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 800px) {
  #documentBar { flex-wrap: wrap; gap: 8px; }
  .app-brand { font-size: 13px; }
  .app-brand small { display: none; }
  .brand-icon { width: 28px; height: 28px; font-size: 18px; }
  .document-title { flex: 1; }
  #docName { width: 100%; }
  .file-actions { margin-left: auto; }
  #documentBar button { padding: 6px 10px; }
  #dirtyMark.dirty { font-size: 10px; }
  #toolbar .tb-sep { display: none; }
  #palette, #props { position: absolute; top: 0; bottom: 0; z-index: 12; box-shadow: 0 6px 20px #12283d20; }
  #palette { left: 0; width: 220px; }
  #props { right: 0; width: 260px; max-width: 85vw; }
  #hint { font-size: 9px; }
}
@media (max-width: 480px) {
  #toolbar .tb-group { flex-wrap: wrap; max-width: 100%; }
  #toolbar { max-height: 36vh; overflow-y: auto; }
  .pipe-mode-tools label span { display: none; }
  #documentBar { gap: 6px; padding: 8px; }
  .file-actions { flex-wrap: wrap; max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* 实物设备端口名只在交互时显示，不写入设备图片。 */
#canvas .photo-port-badge { opacity: 0; pointer-events: none; }
#canvas .photo-symbol-ports.ports-active .photo-port-badge,
#canvas .photo-symbol-ports:hover .photo-port-badge { opacity: 1; }
#canvas .photo-symbol-ports .port { cursor: crosshair; }
.named-port-list { border: 1px solid #dfe9f2; border-radius: 7px; overflow: hidden; background: #f9fcff; }
.named-port-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 9px; font-size: 11px; }
.named-port-row + .named-port-row { border-top: 1px solid #e8eff5; }
.named-port-row > span:first-child { display: flex; align-items: center; gap: 6px; color: #325a7b; }
.named-port-row > span:last-child { color: #758ca0; }
.named-port-row i { width: 6px; height: 6px; border-radius: 50%; background: #438aca; box-shadow: 0 0 0 2px #e1effc; }
.photo-port-note { margin-bottom: 13px; }
.pipe-endpoint { display: flex; align-items: flex-start; gap: 9px; padding: 9px 0; border-bottom: 1px solid #edf1f5; font-size: 11px; }
.endpoint-label { color: #8a9ba9; padding: 2px 0; flex-shrink: 0; }
.pipe-endpoint > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.pipe-endpoint strong { color: #3e5f79; font-weight: 500; }
.pipe-endpoint div > span { color: #7291aa; }


/* ---------- 设备参数与工况估算 ---------- */
.equipment-props { margin: 14px 0; }
.equipment-group { margin: 7px 0; border: 1px solid #dce5ed; border-radius: 7px; background: #fff; overflow: hidden; }
.equipment-group > summary { padding: 9px; color: #44617b; background: #f5f8fb; cursor: pointer; font-size: 12px; font-weight: 600; }
.equipment-group > summary:focus-visible, .equipment-calculation-details > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.equipment-fields { padding: 10px 9px 3px; }
.equipment-unit { color: #5e768b; font-size: 11px; }
.equipment-required { color: #a96737; }
.equipment-default { color: #977444; font-size: 10px; font-weight: 400; white-space: nowrap; }
.equipment-note { margin: 5px 0 9px; color: #748697; font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
.equipment-result { margin: 9px 0 14px; padding: 10px; border-radius: 7px; background: #f5f9fd; border: 1px solid #d7e5f2; }
.equipment-result-heading { font-size: 12px; color: #365c7b; font-weight: 600; margin-bottom: 9px; }
.equipment-result-heading > span { display: block; font-size: 10px; font-weight: 400; color: #738ca2; margin-top: 3px; }
.equipment-result-state { font-size: 11px; line-height: 1.7; color: #57728b; overflow-wrap: anywhere; }
.equipment-result-state.is-warning { color: #986329; }
.equipment-result-state.is-loading { color: #267cce; }
.equipment-result-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(85px,1fr)); gap: 6px; margin: 8px 0; }
.equipment-result-cards > div { min-width: 0; background: #fff; border: 1px solid #e0e9f1; padding: 9px 7px; border-radius: 5px; }
.equipment-result-cards span { display: block; color: #6b8296; font-size: 10px; margin-bottom: 4px; }
.equipment-result-cards strong { color: #245780; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.equipment-result-cards small { color: #7c92a5; font-weight: 400; font-size: 10px; }
.equipment-calculation-details { margin-top: 9px; color: #5d7489; font-size: 11px; line-height: 1.7; }
.equipment-calculation-details summary { cursor: pointer; }
.equipment-calculation-details dl { margin: 8px 0; }
.equipment-calculation-details dl > div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid #e0e9f1; }
.equipment-calculation-details dd { margin: 0; text-align: right; color: #3d5d76; }
.equipment-calculation-details ul { margin: 8px 0; padding-left: 16px; }


/* ---------- 对应设备型号参数库 ---------- */
.equipment-catalog { margin: 12px 0; padding: 10px; border: 1px solid #d7e5f2; border-radius: 7px; background: #f6faff; }
.equipment-catalog h3 { font-size: 12px; font-weight: 600; color: #365c7b; margin: 0 0 9px; }
.equipment-catalog input[type=search] { width: 100%; min-width: 0; padding: 6px 7px; border: 1px solid var(--border-strong); border-radius: 6px; font: inherit; font-size: 12px; background: #fff; }
.equipment-catalog .btn-plain { font-size: 12px; color: #245f96; border-color: #bad1e6; background: #fff; }
.equipment-catalog .btn-plain:disabled { color: #96a5b2; border-color: #dce5ed; cursor: default; }
.equipment-catalog > .equipment-note:last-child { margin-bottom: 0; }
.catalog-source { font-size: 10px; line-height: 1.65; color: #6c8092; overflow-wrap: anywhere; }
.catalog-source strong, .catalog-source > span { display: block; }
.catalog-source strong { color: #58748e; font-weight: 500; }
.catalog-source ul { margin: 5px 0 8px; padding-left: 14px; }
.equipment-calculation-details dd { min-width: 0; overflow-wrap: anywhere; }
.equipment-catalog .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
#pCatalogApplied.is-warning { color: #986329; }
