.algorithm-flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 0;
  margin: 0 0 18px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  overflow-x: auto;
}
.algorithm-flow a {
  position: relative;
  min-width: 120px;
  padding: 10px 12px;
  border-right: 1px solid var(--gray-200);
  color: var(--gray-600);
  font-size: 12px;
}
.algorithm-flow a:last-child { border-right: 0; }
.algorithm-flow a { text-decoration: none; }
.algorithm-flow a:hover { background: var(--gray-50); }
.algorithm-flow a.active:hover { background: var(--primary-light); }
.algorithm-flow a.active { color: var(--primary-dark); background: var(--primary-light); font-weight: 600; }
.algorithm-flow b { display: block; color: inherit; font-size: 12px; }
.algorithm-flow small { display: block; margin-top: 2px; color: var(--gray-500); font-weight: 400; }
.algorithm-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
#asset-definitions .field-full { grid-column: 1 / -1; }
#asset-definitions textarea { min-height: 96px; }
#asset-definitions #definition-editor { margin-top: 12px; }
#asset-definitions #definition-form { margin-top: 12px; }
#asset-definitions .field[hidden] { display: none; }
.algorithm-side { position: sticky; top: 18px; }
.algorithm-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.algorithm-summary > div { min-width: 0; padding: 11px 12px; border: 1px solid var(--gray-200); background: #fff; }
.algorithm-summary small { display: block; color: var(--gray-500); font-size: 11px; }
.algorithm-summary strong { display: block; margin-top: 4px; color: var(--gray-900); font-size: 14px; overflow-wrap: anywhere; }
.contract-pair { display: grid; grid-template-columns: 1fr 42px 1fr; align-items: center; gap: 10px; }
.contract-pair > span { text-align: center; color: var(--gray-400); }
.code-workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr) 280px; min-height: 430px; border: 1px solid var(--gray-200); background: #fff; }
.code-tree, .code-inspector { min-width: 0; padding: 14px; background: var(--gray-50); }
.code-tree { border-right: 1px solid var(--gray-200); }
.code-inspector { border-left: 1px solid var(--gray-200); }
.code-tree ul { margin: 10px 0 0; padding: 0; list-style: none; }
.code-tree li { margin: 0; color: var(--gray-600); font-size: 12px; }
.code-pane-heading, .code-editor-toolbar, .code-statusbar, .code-terminal-command {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.code-file {
  width: 100%;
  padding: 7px 8px;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--gray-600);
  font: 12px/1.45 Consolas, "Cascadia Code", monospace;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.code-file:hover { color: var(--primary); background: #fff; }
.code-file.active { color: var(--primary-dark); background: var(--primary-light); font-weight: 600; }
.code-new-panel { margin: 10px 0; padding: 10px; border: 1px solid var(--gray-200); background: #fff; }
.code-new-panel label { display: block; margin-bottom: 6px; color: var(--gray-600); font-size: 11px; }
.code-new-panel input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  margin-bottom: 8px;
  padding: 6px 8px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.code-editor { display: flex; min-width: 0; padding: 0; overflow: hidden; flex-direction: column; background: #fff; }
.code-editor-toolbar { min-height: 54px; padding: 8px 12px; border-bottom: 1px solid var(--gray-200); }
.code-editor-toolbar > div { display: flex; min-width: 0; align-items: center; gap: 8px; }
.code-editor-input {
  width: 100%;
  min-height: 420px;
  flex: 1 1 auto;
  resize: vertical;
  padding: 16px 18px;
  border: 0;
  outline: 0;
  background: #fbfcfe;
  color: #223047;
  font: 13px/1.75 Consolas, "Cascadia Code", monospace;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
}
.code-statusbar { min-height: 30px; justify-content: flex-end; padding: 4px 10px; border-top: 1px solid var(--gray-200); color: var(--gray-500); font-size: 11px; }
.code-inspector h3 { margin-bottom: 14px; font-size: 14px; }
.code-inspector .field { margin-bottom: 12px; }
.code-inspector .field input, .code-inspector .field select { width: 100%; min-width: 0; min-height: 34px; padding: 6px 8px; border: 1px solid var(--gray-300); background: #fff; }
.code-terminal-panel { margin-top: 18px; }
.code-registry { margin-top: 18px; }
.code-registry h2 { font-size: 16px; }
.code-registry #code-registry-items { margin: 12px 0; }
.code-registry #code-registry-editor { border-top: 1px solid var(--gray-200); padding: 12px 0; }
.code-registry #code-registry-form { margin-top: 12px; }
.code-registry-wide { grid-column: 1 / -1; }
.code-registry #code-registry-detail { margin-top: 12px; }
.code-registry #code-registry-detail pre { max-height: 260px; overflow: auto; padding: 12px; background: var(--gray-50); }
.code-terminal-panel .run-console { min-height: 150px; max-height: 260px; margin: 0; border-radius: 0; white-space: pre-wrap; }
.code-terminal-command { padding: 10px 12px; border-top: 1px solid #2f3b52; background: #172033; color: #d7e2f0; }
.code-terminal-command input { min-width: 0; flex: 1 1 auto; height: 34px; padding: 6px 9px; border: 1px solid #46536a; border-radius: var(--radius-sm); background: #111827; color: #eef4ff; }
.workflow-editor { display: grid; grid-template-columns: 210px minmax(420px, 1fr) 290px; min-height: 520px; border: 1px solid var(--gray-200); background: #fff; }
.component-palette, .node-inspector { padding: 14px; background: var(--gray-50); }
.component-palette { border-right: 1px solid var(--gray-200); }
.node-inspector { border-left: 1px solid var(--gray-200); }
.component-item { margin-top: 8px; padding: 9px; border: 1px solid var(--gray-200); background: #fff; font-size: 12px; cursor: grab; }
.workflow-canvas {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  align-content: center;
  gap: 42px 76px;
  padding: 42px;
  background: linear-gradient(var(--gray-200) 1px, transparent 1px), linear-gradient(90deg, var(--gray-200) 1px, transparent 1px);
  background-size: 24px 24px;
}
.canvas-node { position: relative; padding: 12px; border: 1px solid var(--gray-300); border-left: 3px solid var(--primary); background: #fff; box-shadow: var(--shadow); }
.canvas-node.is-failed { border-left-color: var(--danger); }
.canvas-node strong, .canvas-node small { display: block; }
.canvas-node small { margin-top: 3px; color: var(--gray-500); font-size: 11px; }
.canvas-port { position: absolute; top: 50%; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.canvas-port.in { left: -6px; }.canvas-port.out { right: -6px; }
.run-console { max-height: 270px; overflow: auto; padding: 12px; background: #172033; color: #d7e2f0; font: 12px/1.75 Consolas, monospace; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; border: 1px solid var(--gray-200); background: var(--gray-200); }
.diff-pane { padding: 14px; background: #fff; }
.diff-added { background: #edf7f1; }.diff-removed { background: #fff0f0; }
.gate-list { display: grid; gap: 8px; }
.gate-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--gray-200); }
.gate-item:last-child { border-bottom: 0; }
.gate-item > div > small { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.gate-icon { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--success-bg); color: var(--success); font-weight: 700; }
.v2-toast { position: fixed; right: 20px; bottom: 20px; z-index: 40; max-width: 360px; padding: 10px 14px; border: 1px solid var(--primary-border); border-radius: 6px; background: #fff; box-shadow: var(--shadow-md); color: var(--gray-800); font-size: 13px; }
.v2-toast.is-bad { border-color: var(--danger-border); color: var(--danger); }
.icon-command { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.dependency-workspace { padding:16px 0; border-bottom:1px solid var(--gray-200); margin:16px 0; }
.dependency-workspace .form-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin:12px 0; }
.dependency-workspace .field { min-width:0; }
.dependency-workspace input { width:100%; }
.dependency-workspace td,.dependency-workspace p { overflow-wrap:anywhere; }
.dependency-workspace pre { white-space:pre-wrap; overflow-wrap:anywhere; font-size:12px; }
.dependency-workspace details { margin-top:12px; }
@media (max-width: 1100px) {
  .algorithm-layout { grid-template-columns: 1fr; }
  .algorithm-side { position: static; }
  .code-workspace { grid-template-columns: 190px minmax(0, 1fr); }
  .workflow-editor { grid-template-columns: 190px minmax(360px, 1fr); overflow-x: auto; }
  .code-inspector { grid-column: 1 / -1; border-top: 1px solid var(--gray-200); border-left: 0; }
  .node-inspector { display: none; }
}
@media (max-width: 700px) {
  .dependency-workspace .form-grid { grid-template-columns:minmax(0,1fr); }
  .algorithm-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contract-pair, .diff-grid { grid-template-columns: 1fr; }
  .contract-pair > span { transform: rotate(90deg); }
  .code-workspace, .workflow-editor { grid-template-columns: 1fr; min-height: 0; overflow: visible; }
  .code-tree, .component-palette { border: 0; border-bottom: 1px solid var(--gray-200); }
  .code-tree ul { display: flex; gap: 4px; overflow-x: auto; }
  .code-tree li { flex: 0 0 auto; max-width: 220px; }
  .code-editor-toolbar { align-items: flex-start; flex-direction: column; }
  .code-editor-toolbar .action-group { width: 100%; }
  .code-editor-toolbar .action-group .btn { flex: 1 1 auto; }
  .code-editor-input { min-height: 380px; font-size: 12px; }
  .code-statusbar { justify-content: flex-start; overflow-x: auto; }
  .code-terminal-command { align-items: stretch; flex-wrap: wrap; }
  .code-terminal-command input { flex-basis: calc(100% - 72px); }
  .workflow-canvas { grid-template-columns: 1fr; min-width: 0; padding: 24px; }
}
.asset-catalog-table td:last-child { min-width:110px; }
.asset-catalog-table td .action-group { flex-wrap:nowrap !important; }
.asset-catalog-id { display:block; color:var(--gray-500); margin-top:4px; }
#asset-record-detail > [role="tabpanel"] { padding:20px 0; }
#asset-record-detail h3 { font-size:15px; margin:20px 0 12px; }
#asset-record-detail h3:first-child { margin-top:0; }
#asset-record-detail .asset-change { padding:12px 0; border-bottom:1px solid var(--gray-200); }
#asset-record-detail .asset-change > p { margin:0 0 12px; overflow-wrap:anywhere; }
#asset-record-detail [role="tabpanel"][hidden] { display:none; }
#asset-record-detail .desc { grid-template-columns:100px minmax(0,1fr); gap:12px 16px; }
#asset-record-detail .desc :is(dt,dd) { margin:0; }
#workspace-registry:not(.workspace-parameters-view) > #workspace-parameters { display:none; }
#workspace-registry [data-reference-open="workspace-editor"] { display:none; }
#workspace-registry { border:0; background:transparent; }
#workspace-registry.workspace-parameters-view > .card-b > .reference-surface-entry { display:none; }
#workspace-registry > .card-b:has(> #workspace-overview[hidden]) { padding:0; }
@media (min-width:1100px) {
  #asset-record-detail #detail-panel-overview > .desc { grid-template-columns:100px minmax(0,1fr) 100px minmax(0,1fr); }
}
@media (max-width:700px) {
  #asset-record-detail .desc { grid-template-columns:80px minmax(0,1fr); gap:14px 12px; }
}
#asset-definitions[hidden], #component-packages[hidden] { display:none; }
#definition-editor [hidden] { display:none !important; }
#definition-editor > [role="tabpanel"] { padding:16px 0; min-width:0; }
#definition-editor h3 { margin:0 0 16px; font-size:15px; }
#definition-editor .desc { grid-template-columns:100px minmax(0,1fr); gap:12px 16px; margin:0 0 24px; }
#definition-editor .desc :is(dt,dd) { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; min-width:0; }
#definition-history .tbl { min-width:0; }
#definition-history td { white-space:normal; overflow-wrap:anywhere; }
#definition-history-detail > p { margin:12px 0 24px; overflow-wrap:anywhere; }
#definition-history-back { margin-bottom:20px; }
#definition-editor .definition-change-field { padding:16px 0; border-top:1px solid var(--gray-200); }
#definition-editor .definition-change-field h4 { margin:0 0 12px; font-size:14px; }
#definition-editor .definition-change-field .desc { margin:0; }
@media (max-width:600px) {
  #definition-editor .desc { grid-template-columns:80px minmax(0,1fr); gap:12px; }
  #definition-history .tbl :is(thead) { display:none; }
  #definition-history .tbl :is(tbody,tr,td) { display:block; }
  #definition-history .tbl tr { padding:12px 0; border-bottom:1px solid var(--gray-200); }
  #definition-history .tbl td { padding:4px 0; border:0; }
  #definition-history td[data-label]::before { content:attr(data-label) "："; color:var(--gray-600); }
}
#package-report .tbl { min-width:0; table-layout:fixed; }
#package-report .tbl th { width:34%; white-space:normal; overflow-wrap:anywhere; }
#definition-rows .definition-secondary { color:var(--gray-600); font-size:12px; margin-top:4px; white-space:normal; overflow-wrap:anywhere; }
#package-source-rows td { white-space:pre-wrap; overflow-wrap:anywhere; }
#package-source-download { margin-top:16px; }
.reference-dialog.reference-wide > #asset-config-editor { display:flex; flex-direction:column; overflow:hidden; min-height:0; }
#asset-config-editor #algorithm-form { display:flex; flex-direction:column; flex:1; min-height:0; }
#asset-config-editor #algorithm-form > div:first-child { flex:1; min-height:0; overflow:auto; padding-right:8px; }
#asset-config-editor .algorithm-side { position:static; flex-shrink:0; background:#fff; padding:12px 0 0; border-top:1px solid var(--gray-200); }
#asset-config-editor .algorithm-side .reference-surface-entry { margin-top:8px; }
/* Snapshot configuration stays inside the shared right-side surface. */
.main #debug-snapshot-editor .reference-dialog-footer { position:sticky; bottom:0; background:#fff; }
.main .debug-snapshot-content { max-width:100%; overflow:auto; white-space:pre; font-size:13px; line-height:1.6; }
@media (max-width:600px) {
  #code-history-panel[data-history-scope="environment"] .tbl { min-width:0; width:100%; }
  #code-history-panel[data-history-scope="environment"] .tbl thead { display:none; }
  #code-history-panel[data-history-scope="environment"] .tbl tbody { display:block; }
  #code-history-panel[data-history-scope="environment"] .tbl tr {
    display:grid; grid-template-columns:minmax(0,1fr) auto; padding:12px 0; border-bottom:1px solid var(--gray-200);
  }
  #code-history-panel[data-history-scope="environment"] .tbl td {
    min-width:0; padding:4px 0; border:0;
  }
  #code-history-panel[data-history-scope="environment"] .tbl td:nth-child(-n+2) { grid-column:1 / -1; }
  #code-history-panel[data-history-scope="environment"] .tbl td:nth-child(3),
  #code-history-panel[data-history-scope="environment"] .tbl td:nth-child(4) { grid-column:1; }
  #code-history-panel[data-history-scope="environment"] .tbl td[data-label]::before {
    content:attr(data-label) ": "; color:var(--gray-500);
  }
  #code-history-panel[data-history-scope="environment"] .tbl td:last-child:not([colspan]) {
    grid-column:2; grid-row:3 / 5; align-self:center; padding-left:12px;
  }
}
