:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --line: #d5dce3;
  --text: #12212f;
  --muted: #4e6072;
  --accent: #0e7ac4;
  --danger: #ba1f36;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 15% 0%, #ffffff 0, #ebf1f6 45%, #dee6ef 100%);
  overflow: hidden;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.menu-bar {
  display: flex;
  gap: 2px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.menu-status {
  margin-left: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  padding-right: 8px;
}

.menu-file-status {
  margin-left: auto;
  color: #3d556b;
  font-size: 0.9rem;
  white-space: nowrap;
  max-width: 36vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-nav-btn {
  margin-left: 10px;
  border: 1px solid var(--line);
  background: #f7fafc;
  color: #274357;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.menu-breadcrumb {
  margin-left: 10px;
  color: #5a6e80;
  font-size: 0.86rem;
  white-space: nowrap;
  max-width: 24vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-time {
  margin-left: 12px;
  color: #3d556b;
  font-size: 0.9rem;
  white-space: nowrap;
}

.menu-root {
  position: relative;
}

.menu-title {
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 7px 12px;
  cursor: default;
}

.menu-title:hover,
.menu-root.open .menu-title {
  background: #e9f3fc;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  display: none;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(18, 33, 47, 0.12);
  z-index: 900;
}

.menu-root.open .menu-panel {
  display: block;
}

.menu-command {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
}

.menu-command:hover:not(:disabled) {
  background: #ebf5ff;
}

.menu-shortcut {
  color: #6b7b8b;
  font-size: 0.82rem;
}

.menu-sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 6px 2px;
}

.menu-check {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: var(--text);
}

.menu-field {
  margin: 6px 8px 4px;
}

#gridSizeInput {
  width: 100%;
}

.layout {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.canvas-wrap {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 320px;
  padding: 12px;
  overflow: auto;
  min-width: 0;
  isolation: isolate;
  z-index: 1;
  background:
    linear-gradient(rgba(122, 146, 170, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 146, 170, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, #ffffff 0, #eef3f8 40%, #e3eaf2 100%);
  background-size: 24px 24px, 24px 24px, auto;
  background-position: 0 0, 0 0, 0 0;
}

.canvas-content {
  position: relative;
  width: max-content;
  height: max-content;
}

#graphCanvas {
  width: 1200px;
  height: 800px;
  background: transparent;
  touch-action: none;
  display: block;
  position: relative;
  z-index: 0;
}

.widget-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.value-widget {
  position: absolute;
  pointer-events: auto;
  min-width: 220px;
  min-height: 110px;
  border: 1px solid #9ab4cc;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(18, 33, 47, 0.12);
  overflow: hidden;
}

.value-widget.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(14, 122, 196, 0.18), 0 8px 20px rgba(18, 33, 47, 0.12);
}

.value-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #e9f3fc;
  color: #0f4772;
  padding: 3px 6px;
  border-bottom: 1px solid #c4d9ec;
  cursor: move;
  user-select: none;
  font-size: 0.82rem;
  line-height: 1.1;
}

.value-widget-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.value-widget-header button {
  margin: 0;
  padding: 1px 6px;
  min-width: 22px;
  min-height: 20px;
  font-size: 0.76rem;
  border-color: #d6a1ab;
  color: var(--danger);
  background: #fff4f6;
}

.value-widget.minimized .value-widget-body,
.value-widget.minimized .value-widget-resize {
  display: none;
}

.value-widget.minimized {
  height: 28px !important;
  min-height: 28px;
}

.value-widget-body {
  height: calc(100% - 28px);
  overflow: auto;
  padding: 8px;
}

.value-widget table {
  width: 100%;
  border-collapse: collapse;
}

.value-widget th,
.value-widget td {
  border: 1px solid #d9e2ea;
  padding: 4px 6px;
  vertical-align: top;
}

.value-widget th select {
  width: 100%;
}

.xy-chart-body {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  overflow: hidden;
}

.xy-chart-config {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  align-items: end;
}

.xy-chart-y-select {
  min-height: 74px;
}

.xy-chart-canvas-wrap {
  min-height: 0;
}

.xy-chart-actions {
  display: grid;
  gap: 6px;
}

.xy-chart-canvas {
  width: 100%;
  height: 100%;
  min-height: 90px;
  border: 1px solid #d9e2ea;
  border-radius: 6px;
  background: #fff;
}

.slider-widget-wrap {
  display: grid;
  gap: 10px;
}

.slider-widget-source {
  font-size: 12px;
  color: #4e6072;
}

.slider-widget-wrap input[type="range"] {
  width: 100%;
  margin: 0;
}

.slider-range-line {
  display: grid;
  grid-template-columns: auto 1fr 96px auto;
  gap: 8px;
  align-items: center;
}

.slider-bound {
  font-size: 12px;
  color: #4e6072;
  white-space: nowrap;
}

.slider-widget-value {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #1f3e58;
}

.slider-value-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 8px;
  align-items: center;
}

.slider-widget-number {
  margin-top: 0;
  width: 100%;
}

.value-widget-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 0 35%, #9ab4cc 35% 100%);
}

.sidebar {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 300px;
  min-width: 0;
  border-left: 1px solid var(--line);
  padding: 14px;
  background: var(--surface);
  overflow: hidden;
  isolation: isolate;
  z-index: 2;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
}

h2,
h3,
h4 {
  margin: 0 0 10px;
}

.panel,
#noSelection {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfe;
  max-height: 100%;
  overflow: auto;
}

#globalPanel {
  margin-top: 10px;
  padding: 4px;
  display: grid;
  gap: 4px;
}

#globalPanel.hidden {
  display: none;
}

.row2-exec {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.time-row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}

.time-row3 label {
  margin-top: 0;
}

.row3-exec {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}

.compact-field {
  display: grid;
  gap: 4px;
  margin-top: 0;
}

.compact-field span {
  font-size: 12px;
  color: #4e6072;
}

.run-icons-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.model-section {
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid #dbe4ec;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

#globalPanel h3 {
  margin: 0;
  font-size: 0.95rem;
}

#globalPanel h4 {
  margin: 0;
  font-size: 0.84rem;
}

#globalPanel label {
  margin: 0 0 2px;
  font-size: 0.78rem;
}

#globalPanel input,
#globalPanel select {
  padding: 3px 5px;
  min-height: 26px;
  font-size: 0.88rem;
}

.model-compact-row {
  grid-template-columns: 1fr 1fr;
  align-items: end;
}

.model-meta-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  align-items: end;
}

.model-current-inline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.model-current-inline label {
  margin: 0;
  white-space: nowrap;
}

.model-properties-section {
  align-content: start;
}

#globalPanel .compact-check {
  margin: 0;
  min-height: 100%;
  padding: 1px 0;
  font-size: 0.76rem;
  line-height: 1.1;
}

#globalPanel .compact-check span {
  white-space: normal;
}

#globalPanel .small-btn {
  margin-top: 0;
  padding: 4px 6px;
  font-size: 0.76rem;
  line-height: 1.1;
}

#globalPanel .props-list {
  gap: 4px;
}

#globalPanel .value-output {
  margin: 0;
  min-height: 24px;
  padding: 3px 5px;
  text-align: right;
  font-size: 0.84rem;
}

.icon-btn {
  margin-top: 0;
  padding: 4px 0;
  line-height: 1;
  text-align: center;
  font-size: 0.88rem;
}

@media (max-width: 980px) {
  .row3-exec {
    grid-template-columns: 1fr;
  }

  .model-compact-row {
    grid-template-columns: 1fr;
  }

  .model-current-inline {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .model-current-inline label,
  #globalPanel .value-output {
    text-align: left;
  }
}

.hidden {
  display: none;
}

.app-tooltip {
  position: fixed;
  z-index: 2000;
  max-width: min(320px, calc(100vw - 24px));
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(20, 34, 46, 0.96);
  color: #f6fbff;
  font-size: 0.8rem;
  line-height: 1.35;
  box-shadow: 0 12px 24px rgba(10, 20, 30, 0.24);
  pointer-events: none;
  white-space: normal;
}

.hidden-file {
  display: none;
}

label {
  display: block;
  margin-top: 8px;
  margin-bottom: 4px;
  font-size: 0.88rem;
  color: var(--muted);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(186, 31, 54, 0.18);
}

button {
  border: 1px solid #9ab4cc;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  background: #e9f3fc;
  color: #0f4772;
}

button:hover {
  filter: brightness(0.98);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.small-btn {
  margin-top: 10px;
}

.panel-section {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #dbe4ec;
  border-radius: 8px;
  background: #ffffff;
}

.compact-panel-section {
  gap: 4px;
  padding: 6px;
}

#nodePanel,
#widgetPanel {
  display: grid;
  gap: 6px;
}

#nodePanel.hidden,
#widgetPanel.hidden {
  display: none;
}

#nodePanel h3,
#widgetPanel h3 {
  margin: 0;
  font-size: 0.95rem;
}

#nodePanel h4,
#widgetPanel h4 {
  margin: 0;
  font-size: 0.84rem;
}

#nodePanel label,
#widgetPanel label {
  margin: 0 0 2px;
  font-size: 0.78rem;
}

#nodePanel input,
#nodePanel select,
#nodePanel textarea,
#widgetPanel input,
#widgetPanel select {
  padding: 3px 5px;
  min-height: 26px;
  font-size: 0.88rem;
}

#widgetPanel textarea {
  padding: 3px 5px;
  min-height: 26px;
  font-size: 0.88rem;
}

.panel-textarea {
  min-height: 64px;
  resize: vertical;
  line-height: 1.3;
}

.display-only-input {
  user-select: none;
  caret-color: transparent;
}

.expr-inline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
}

#nodeValueExprRow.hidden,
#nodeInitialStateRow.hidden {
  display: none;
}

.expr-inline-row input {
  min-width: 0;
}

.expr-edit-btn {
  margin-top: 0;
  white-space: nowrap;
  padding: 4px 7px;
  font-size: 0.76rem;
  line-height: 1.1;
}

.expr-status {
  margin: 4px 0 8px;
  font-size: 0.8rem;
  line-height: 1.3;
}

.expr-status.ok {
  color: #1f7a38;
}

.expr-status.error {
  color: var(--danger);
}

.value-output {
  margin: 4px 0 10px;
  min-height: 34px;
  max-height: 140px;
  overflow: auto;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.props-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 5;
  pointer-events: auto;
}

.prop-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  pointer-events: auto;
}

.prop-row input {
  position: relative;
  z-index: 6;
  pointer-events: auto;
}

.prop-row button {
  padding: 4px 8px;
  border-color: #d6a1ab;
  color: var(--danger);
  background: #fff4f6;
}

.empty-props {
  padding: 5px 6px;
  border: 1px dashed #c7d5e2;
  border-radius: 6px;
  background: #f8fbfe;
  color: #617689;
  font-size: 0.8rem;
  font-style: italic;
}

.submodel-bindings {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.submodel-bindings-note {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.submodel-binding-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.submodel-binding-row label {
  margin: 0;
  font-size: 0.82rem;
  color: #314659;
}

.submodel-binding-row input {
  min-width: 0;
}

.node-type-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.node-flags-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  margin-top: 1px;
}

.node-type-row .menu-check {
  margin: 0;
  padding: 0;
  white-space: nowrap;
  line-height: 1.05;
}

.node-flags-col .menu-check input {
  transform: scale(0.92);
  transform-origin: left center;
}

.widget-config-grid {
  display: grid;
  gap: 6px;
}

#nodePanel .small-btn,
#widgetPanel .small-btn {
  margin-top: 0;
  padding: 4px 6px;
  font-size: 0.76rem;
  line-height: 1.1;
}

#nodePanel .props-list,
#widgetPanel .props-list {
  gap: 4px;
}

#widgetPanel .menu-check.compact-bool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1.1;
}

#widgetPanel .menu-check.compact-bool input {
  width: 12px;
  height: 12px;
  min-height: 12px;
}

#widgetPanel .menu-check.compact-bool span {
  white-space: nowrap;
}

.chart-pair-row {
  display: grid;
  gap: 4px;
}

.chart-pair-list {
  display: grid;
  gap: 4px;
}

.chart-pair-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
}

.chart-pair-select-btn,
.chart-pair-delete-btn {
  margin-top: 0;
  padding: 4px 6px;
  font-size: 0.76rem;
  line-height: 1.1;
}

.chart-pair-select-btn {
  text-align: left;
}

.chart-pair-select-btn.active {
  background: #d6ebfb;
  border-color: #7fb0d6;
}

.chart-pair-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.chart-pair-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: center;
}

.chart-pair-style-row {
  display: grid;
  grid-template-columns: auto auto 1fr 84px;
  gap: 4px;
  align-items: center;
}

.chart-pair-style-row input[type="color"] {
  width: 32px;
  min-width: 32px;
  padding: 2px;
}

.edge-line {
  fill: none;
  stroke: #3b4e61;
  stroke-width: 2;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 33, 47, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1400;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 18px 36px rgba(18, 33, 47, 0.22);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: move;
  user-select: none;
}

.modal-head h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-close-btn {
  width: 34px;
  min-width: 34px;
  padding: 6px 0;
  font-size: 1.1rem;
}

.expression-editor-card {
  width: min(1120px, calc(100vw - 40px));
  height: min(78vh, 760px);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
}

.functions-help-card {
  width: min(920px, calc(100vw - 40px));
}

.help-intro {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.functions-help-content {
  overflow: auto;
  max-height: calc(100vh - 220px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.help-group + .help-group {
  margin-top: 14px;
}

.help-group-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #274764;
}

.help-item + .help-item {
  margin-top: 10px;
}

.help-item-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  color: #163650;
}

.help-item-signature {
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: #47627a;
}

.help-item-desc {
  margin-top: 3px;
  font-size: 0.84rem;
  line-height: 1.35;
  color: var(--text);
}

.expression-editor-textarea {
  width: 100%;
  min-height: 0;
  height: 100%;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: 0.95rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  overflow: auto;
}

.expression-help {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  white-space: pre-wrap;
  min-height: 88px;
  max-height: 160px;
  overflow: auto;
}

.expression-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.expression-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.95fr);
  gap: 12px;
  min-height: 0;
}

.expression-editor-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.expression-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
  min-height: 0;
}

.expression-symbols-filter {
  padding: 6px 8px;
  font-size: 0.84rem;
}

.expression-library {
  max-height: none;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  min-height: 0;
}

.expression-library-group + .expression-library-group {
  margin-top: 10px;
}

.expression-library-title {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 0 6px;
  padding: 2px 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #274764;
  background: #fbfcfe;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.expression-library-list {
  display: grid;
  gap: 4px;
}

.expression-library-item {
  display: block;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.expression-library-item:hover,
.expression-library-item.active {
  background: #e5f1fb;
}

.expression-library-item:hover {
  border-color: #cfe0ee;
}

.expression-library-item.active {
  border-color: #7fb0d6;
  box-shadow: inset 3px 0 0 #0e7ac4;
}

.expression-library-item:focus-visible {
  outline: 2px solid rgba(14, 122, 196, 0.28);
  outline-offset: 1px;
}

.expression-library-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  font-weight: 600;
  color: #163650;
}

.expression-library-name mark {
  padding: 0 1px;
  border-radius: 3px;
  background: #fff1a8;
  color: inherit;
}

.expression-editor-hint {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
  text-align: right;
}

.expression-editor-textarea.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(186, 31, 54, 0.18);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 980px) {
  .expression-editor-card {
    width: min(920px, calc(100vw - 24px));
    height: min(86vh, 860px);
  }

  .expression-editor-layout {
    grid-template-columns: 1fr;
  }

  .expression-editor-textarea {
    min-height: min(36vh, 320px);
    height: min(36vh, 320px);
  }

  .expression-editor-hint {
    text-align: left;
  }
}

.edge-hit {
  fill: none;
  stroke: #000;
  stroke-opacity: 0.001;
  stroke-width: 14;
  cursor: pointer;
  pointer-events: stroke;
}

.edge-drag-preview {
  fill: none;
  stroke: #0e7ac4;
  stroke-width: 2;
  stroke-dasharray: 8 5;
  opacity: 0.85;
  pointer-events: none;
}

.node-shape {
  fill: #fcfdff;
  stroke: #2f4a62;
  stroke-width: 2;
  cursor: inherit;
}

.node-shape-inner {
  fill: none;
  stroke: #2f4a62;
  stroke-width: 1.5;
  pointer-events: none;
}

.node.invalid-definition .node-shape {
  fill: #fff5f6;
  stroke: #ba1f36;
  stroke-width: 2.5;
  stroke-dasharray: 7 4;
}

.node.invalid-definition .node-shape-inner {
  stroke: #ba1f36;
  stroke-dasharray: 7 4;
}

.node-label {
  font-size: 16px;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}

.node-output-badge {
  fill: #e67e22;
  stroke: #a85612;
  stroke-width: 1;
  pointer-events: none;
}

.node-input-badge {
  fill: #2aa876;
  stroke: #1e7251;
  stroke-width: 1;
  pointer-events: none;
}

.node-input-badge-label,
.node-output-badge-label {
  font-size: 9px;
  font-weight: 700;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}

.submodel-port {
  stroke-width: 1;
  pointer-events: none;
}

.submodel-port.input {
  fill: #2aa876;
  stroke: #1e7251;
}

.submodel-port.output {
  fill: #e67e22;
  stroke: #a85612;
}

.node.selected .node-shape {
  stroke: var(--accent);
  stroke-width: 3;
}

.node.edge-target .node-shape {
  stroke: #e67e22;
  stroke-width: 3;
  stroke-dasharray: 7 4;
}

.edge.selected .edge-line {
  stroke: var(--accent);
  stroke-width: 3;
}

.resize-handle {
  fill: var(--accent);
  cursor: nwse-resize;
}

.center-port-hit {
  fill: #000;
  fill-opacity: 0.001;
  pointer-events: fill;
  cursor: crosshair;
}

.control-point {
  fill: #fff;
  stroke: #0e7ac4;
  stroke-width: 2;
  cursor: move;
}

.edge.selected .control-point {
  fill: #dff2ff;
}

.control-point.active,
.edge.selected .control-point.active {
  fill: #0e7ac4;
}

.node:not(.selected) .resize-handle {
  display: none;
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 156px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(18, 33, 47, 0.14);
  padding: 5px;
}

.context-menu-sep {
  border: 0;
  border-top: 1px solid #d9e2ea;
  margin: 4px 2px;
}

.context-menu button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 7px 9px;
  border-radius: 6px;
}

.context-menu button:hover:not(:disabled) {
  background: #ebf5ff;
}

.context-menu button:disabled {
  color: #8ea0b2;
}

@media (max-width: 940px) {
  .layout {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    position: static;
    right: auto;
  }

  .sidebar {
    position: static;
    width: auto;
    right: auto;
    top: auto;
    bottom: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
