.ws-layout {
  --ws-side-w: 260px;
  --ws-panel-w: 380px;
  display: grid;
  grid-template-columns: var(--ws-side-w) 6px 1fr 0 0;
  height: calc(100vh - 64px);
  max-height: calc(100vh - 64px);
  overflow: hidden;
  transition: grid-template-columns 0.18s ease;
}

.ws-layout.ws-layout--panel {
  grid-template-columns: var(--ws-side-w) 6px 1fr 6px var(--ws-panel-w);
}

.ws-layout.ws-layout--dragging {
  transition: none;
  user-select: none;
  cursor: col-resize;
}

.ws-split {
  width: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--surface-2);
  cursor: col-resize;
  position: relative;
  z-index: 5;
}

.ws-split::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: transparent;
  transition: background 0.12s;
}

.ws-split:hover,
.ws-split:focus-visible {
  outline: none;
  background: #2e3036;
}

.ws-split:hover::after,
.ws-split:focus-visible::after {
  background: #a3abff;
}

.ws-split.hidden {
  display: none;
}

.ws-side {
  background: var(--surface);
  border-right: 0;
  padding: 10px 10px 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.ws-fold {
  padding: 0.15rem 0 0.35rem;
  border-bottom: 1px solid rgba(34, 36, 41, 0.9);
}

.ws-fold:last-child {
  border-bottom: 0;
}

.ws-fold--nested {
  margin: 0.35rem 0 0;
  padding: 0.25rem 0 0;
  border-bottom: 0;
  border-top: 1px dashed #222429;
}

.ws-fold > :not(summary) {
  margin-top: 0.4rem;
}

.ws-fold__sum {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0.35rem 0.2rem;
  user-select: none;
}

.ws-fold__sum::-webkit-details-marker,
.ws-fold__sum::marker {
  display: none;
  content: '';
}

.ws-fold__sum::before {
  content: '';
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid #6b6f76;
  flex-shrink: 0;
  transition: transform 0.12s ease;
}

.ws-fold[open] > .ws-fold__sum::before {
  transform: rotate(90deg);
}

.ws-fold__sum:hover {
  color: var(--text);
}

.ws-fold__count {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  color: #8a8f98;
  background: #111214;
  border: 1px solid #222429;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

.ws-fold__count[hidden] {
  display: none;
}

.ws-fold__toolbar {
  display: flex;
  justify-content: flex-end;
}

.ws-side__block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ws-side__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.ws-side__row .sidebar__title {
  margin: 0;
}

.btn--tiny {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

.ws-save-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 4.5rem;
}

.ws-list,
.ws-palette {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ws-list__item,
.ws-palette__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.82rem;
}

.ws-list__item:hover,
.ws-palette__item:hover {
  border-color: var(--border);
}

.ws-list__item--active {
  border-color: var(--border);
  background: var(--bg);
}

.ws-palette__item {
  cursor: grab;
  user-select: none;
}

.ws-palette__meta {
  flex-shrink: 0;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.ws-main {
  display: grid;
  grid-template-rows: 1fr 160px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.ws-marquee {
  position: fixed;
  z-index: 40;
  border: 1px solid #a3abff;
  background: rgba(110, 123, 242, 0.14);
  pointer-events: none;
}

#drawflow.ws-panning,
#drawflow.ws-panning * {
  cursor: grabbing !important;
}

.ws-canvas {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

#drawflow {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--text) 16%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
  background-color: var(--bg);
  overflow: hidden;
}

.ws-canvas .ws-zoom {
  top: auto;
  right: 10px;
  bottom: 10px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.minimap-wrap {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 6;
  padding: 6px 6px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  pointer-events: none;
}

.minimap-wrap__label {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ws-canvas .minimap {
  position: static;
  display: block;
  width: 148px;
  height: 72px;
  background: var(--bg);
  border: 0;
  border-radius: 4px;
  pointer-events: auto;
  cursor: crosshair;
  touch-action: none;
}

.ws-log {
  border-top: 1px solid var(--surface-2);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ws-log__title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.45rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--surface-2);
  background: transparent;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
}

.ws-log__title::before {
  content: '';
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transform: rotate(90deg);
}

.ws-main--log-shut .ws-log__title::before {
  transform: none;
}

.ws-main--log-shut {
  grid-template-rows: 1fr 34px;
}

.ws-main--log-shut .ws-log__body,
.ws-main--log-shut .ws-log__title {
  border-bottom: 0;
}

.ws-main--log-shut .ws-log__body {
  display: none;
}

.ws-log__body {
  margin: 0;
  padding: 0.65rem 1rem;
  overflow: auto;
  flex: 1;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text);
  white-space: pre-wrap;
}

/* ── Right panel ── */
.ws-panel {
  border-left: 1px solid var(--surface-2);
  background: #111214;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  width: 100%;
}

.ws-panel.hidden {
  display: none;
}

.ws-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--surface-2);
}

.ws-panel__title {
  font-size: 0.95rem;
  font-weight: 650;
}

.ws-panel__meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-top: 0.15rem;
}

.ws-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--surface-2);
}

.ws-panel__tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--surface-2);
}

.ws-tab {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-size: 0.78rem;
}

.ws-tab--active {
  color: var(--text);
  border-bottom-color: #8a8f98;
}

.ws-tab.hidden,
.ws-panel__actions.hidden,
.hidden {
  display: none !important;
}

.ws-panel__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ws-panel__pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ws-panel__pane.hidden {
  display: none;
}

.monaco-host--ws {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.ws-panel__logs {
  margin: 0;
  padding: 0.75rem 1rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.45;
  color: #d0d3d8;
  white-space: pre-wrap;
  word-break: break-word;
  background: #08090a;
}

.ws-panel__err {
  color: var(--error);
  font-size: 0.75rem;
  padding: 0.35rem 1rem 0.75rem;
  min-height: 1.2rem;
}

/* ── Modal ── */
.ws-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
}

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

.ws-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.ws-modal__card {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(88vh, 900px);
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ws-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--surface-2);
}

.ws-modal__head h2 {
  font-size: 1rem;
}

.ws-modal__fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
}

.monaco-host--modal {
  height: 360px;
  border-top: 1px solid var(--surface-2);
  border-bottom: 1px solid var(--surface-2);
}

.ws-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
}

/* ── Drawflow: quiet nodes & ports ── */
.drawflow {
  background: transparent !important;
}

.drawflow .drawflow-node {
  --ws-port: 14px;
  --ws-port-gap: 12px;
  --ws-accent: #8a8f98;
  background: var(--surface);
  border: 1px solid #222429;
  border-left: 3px solid var(--ws-accent);
  border-radius: 8px;
  color: var(--text);
  width: auto !important;
  min-width: 176px;
  min-height: 52px;
  padding: 0 !important;
  box-shadow: none;
  filter: none !important;
  overflow: visible;
}

.drawflow .drawflow-node:hover {
  border-color: #2e3036;
  border-left-color: var(--ws-accent);
}

.drawflow .drawflow-node.selected {
  background: #16171a !important;
  border-color: #a3abff !important;
  border-left-color: var(--ws-accent) !important;
  box-shadow: 0 0 0 1px var(--accent-ring) !important;
  outline: none !important;
}

.drawflow .drawflow-node .title-box {
  background: transparent;
  border-bottom: 1px solid #222429;
  padding: 0.5rem 0.75rem 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px 8px 0 0;
}

.ws-node:not(:has(.box)) .title-box {
  border-bottom: 0;
  padding-bottom: 0.55rem;
  border-radius: 8px;
}

.drawflow .drawflow-node .box {
  padding: 0.3rem 0.75rem 0.5rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.drawflow .drawflow-node .inputs,
.drawflow .drawflow-node .outputs {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0 !important;
  min-width: 0 !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--ws-port-gap);
  z-index: 4;
}

.drawflow .drawflow-node .inputs {
  left: 0;
}

.drawflow .drawflow-node .outputs {
  right: 0;
}

.drawflow .drawflow-node .input,
.drawflow .drawflow-node .output {
  box-sizing: border-box !important;
  flex: 0 0 14px;
  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  min-height: 14px !important;
  max-width: 14px !important;
  max-height: 14px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  cursor: crosshair;
  z-index: 4;
  top: 0 !important;
}

.drawflow .drawflow-node .input::after,
.drawflow .drawflow-node .output::after {
  content: none !important;
  display: none !important;
}

.drawflow .drawflow-node .input {
  left: 0 !important;
  right: auto !important;
  background: #08090a !important;
  border: 2px solid #6e7bf2 !important;
  transform: translateX(-50%);
}

.drawflow .drawflow-node .output {
  left: auto !important;
  right: 0 !important;
  background: var(--accent) !important;
  border: 2px solid #08090a !important;
  transform: translateX(50%);
}

.drawflow .drawflow-node .input:hover {
  background: #6e7bf2 !important;
  transform: translateX(-50%) scale(1.15);
}

.drawflow .drawflow-node .output:hover {
  background: var(--accent-hover) !important;
  transform: translateX(50%) scale(1.15);
}

.drawflow .connection .main-path {
  stroke: #2e3036 !important;
  stroke-width: 1.75px !important;
}

.drawflow .connection .main-path:hover,
.drawflow .connection .main-path.selected {
  stroke: #8a8f98 !important;
}

.drawflow .drawflow-delete {
  background: #222429;
  border: 1px solid #2e3036;
  color: #d0d3d8;
  box-shadow: none;
}

.drawflow-node.ws-node--running {
  border-color: #6e7bf2 !important;
  border-left-color: var(--ws-accent) !important;
  box-shadow: 0 0 0 1px rgba(110, 123, 242, 0.25) !important;
}

.drawflow-node.ws-node--success {
  border-color: var(--success) !important;
  border-left-color: var(--ws-accent) !important;
}

.drawflow-node.ws-node--error {
  border-color: var(--error) !important;
  border-left-color: var(--ws-accent) !important;
}

.ws-panel__hint,
.ws-vars-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0 0 0.5rem;
}

.ws-panel__hint code,
.ws-vars-hint code {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: #a3abff;
  background: rgba(110, 123, 242, 0.08);
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.ws-config-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.25rem 0;
}

.ws-config-form textarea.input {
  font-family: var(--mono);
  font-size: 0.78rem;
  min-height: 6rem;
  resize: vertical;
}

.ws-palette__item--block .ws-palette__meta {
  opacity: 0.7;
}

.drawflow-node.block-if .outputs,
.drawflow-node.block-switch .outputs,
.drawflow-node.block-loop .outputs,
.drawflow-node.block-retry .outputs {
  /* multi-out spacing handled by drawflow */
}

.header a.btn,
.ws-panel__actions a.btn {
  text-decoration: none;
}

.ws-page .header {
  height: var(--header-h);
  padding: 0 1.25rem;
}

.ws-page .header h1 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

.ws-title {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.1rem;
  cursor: text;
}

.ws-title__input {
  field-sizing: content;
  min-width: 8rem;
  max-width: 38vw;
  margin-left: -0.35rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
}

.ws-title__input:hover {
  border-color: var(--surface-2);
}

.ws-title__input:focus {
  outline: none;
  border-color: var(--wb);
  background: var(--bg);
}

.ws-title__pen {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.ws-page .header__subtitle {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ws-palette__cat {
  list-style: none;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b6f76;
  padding: 0.55rem 0.2rem 0.15rem;
  cursor: default;
}

.ws-node {
  position: relative;
  min-width: 148px;
}

.ws-node--named {
  padding-right: 1.7rem;
}

.ws-node__kind {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b6f76;
  font-family: var(--mono);
  margin-bottom: 0.12rem;
}

.ws-node__ports {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--ws-port-gap, 12px);
  pointer-events: none;
}

.ws-node__port {
  height: var(--ws-port, 14px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 10px;
  font-weight: 650;
  font-family: var(--mono);
  color: #c4b5fd;
  line-height: 1;
  white-space: nowrap;
}

.ws-info {
  padding: 0.85rem 1rem 1.25rem;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ws-info__title {
  font-size: 0.92rem;
  font-weight: 650;
}

.ws-info__lead {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.ws-info__diagram {
  background: #08090a;
  border: 1px solid #222429;
  border-radius: 10px;
  padding: 0.65rem;
  overflow: hidden;
}

.ws-info__diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

.ws-info h3 {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b6f76;
  margin: 0.15rem 0 0.25rem;
}

.ws-info p,
.ws-info pre {
  font-size: 0.78rem;
  line-height: 1.45;
  color: #d0d3d8;
  margin: 0;
}

.ws-info pre {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: #08090a;
  border: 1px solid #222429;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  white-space: pre-wrap;
  color: #a3abff;
}

.rail-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rail-search {
  width: 100%;
}

.rail-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border-radius: 8px;
}

.rail-tabs button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  padding: 6px 2px;
  border-radius: 6px;
  cursor: pointer;
}

.rail-tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

.rail-panes {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.rail-pane[hidden] {
  display: none;
}

.rail-add {
  width: 100%;
  margin-bottom: 6px;
}

.rail-hint {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
}

.rail-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-foot {
  display: flex;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.rail-foot .btn {
  flex: 1;
}

.ws-log__body:empty::before {
  content: 'Запустите доску — шаги появятся здесь.';
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .ws-layout,
  .ws-layout.ws-layout--panel {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }
  .ws-split {
    display: none;
  }
  .ws-side {
    max-height: 42vh;
  }
  .ws-panel {
    max-height: 45vh;
    border-left: 0;
    border-top: 1px solid var(--surface-2);
  }
  .ws-modal__fields {
    grid-template-columns: 1fr;
  }
}
