:root {
  --bg: #f4f0ea;
  --panel: #fffdfa;
  --ink: #172033;
  --muted: #64748b;
  --line: #d9cfc0;
  --accent: #c95f2d;
  --accent-2: #2563eb;
  --green: #0f8f67;
  --shadow: 0 16px 42px rgba(57, 38, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.45 Inter, "Segoe UI", system-ui, sans-serif;
}

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

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: #bcae9a;
}

button.active,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.app-header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(255, 253, 250, 0.92);
  border-bottom: 1px solid var(--line);
}

.app-header strong {
  display: block;
  font-size: 16px;
}

.app-header span {
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  gap: 8px;
}

.workspace {
  height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: 300px minmax(520px, 1fr) 410px;
  gap: 12px;
  padding: 12px;
}

.left-panel,
.right-panel {
  min-height: 0;
  overflow: auto;
}

.left-panel,
.right-panel,
.canvas-shell {
  scrollbar-width: thin;
  scrollbar-color: #b9ab97 transparent;
}

.panel-card,
.canvas-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.panel-card {
  padding: 14px;
  margin-bottom: 12px;
}

.panel-card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a735b;
}

.palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-row {
  display: flex;
  gap: 8px;
}

.mode-row button {
  flex: 1;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title h2 {
  margin-bottom: 0;
}

.inspector label {
  display: block;
  color: #6b5a48;
  font-size: 12px;
  font-weight: 800;
  margin-top: 10px;
}

.inspector input,
.inspector select,
.inspector textarea,
#jsonOutput {
  display: block;
  width: 100%;
  margin-top: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  padding: 8px 9px;
}

.inspector textarea {
  min-height: 76px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
}

.empty {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
}

.canvas-shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.canvas-topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.canvas-topbar span {
  color: var(--muted);
  font-weight: 700;
}

.canvas {
  position: relative;
  flex: 1;
  overflow: auto;
  background-color: #fbfaf7;
  background-image:
    linear-gradient(#eadfd1 1px, transparent 1px),
    linear-gradient(90deg, #eadfd1 1px, transparent 1px);
  background-size: 24px 24px;
}

.edge-layer {
  position: absolute;
  width: 1800px;
  height: 1200px;
  pointer-events: none;
}

.edge-layer path {
  fill: none;
  stroke: #9b8a75;
  stroke-width: 2.5;
  marker-end: url(#arrow);
}

.edge-layer marker path {
  fill: #9b8a75;
}

.node-layer {
  position: absolute;
  width: 1800px;
  height: 1200px;
}

.wf-node {
  position: absolute;
  width: 190px;
  min-height: 82px;
  border: 1px solid #cebda7;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(45, 31, 18, 0.13);
  padding: 12px;
  cursor: grab;
  user-select: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.wf-node:active {
  cursor: grabbing;
}

.wf-node.selected {
  outline: 3px solid rgba(201, 95, 45, 0.32);
  border-color: var(--accent);
}

.wf-node.connect-source {
  outline: 3px solid rgba(37, 99, 235, 0.36);
}

.wf-node .type {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  background: #f5eadc;
  color: #8a4f21;
  font-size: 11px;
  font-weight: 900;
  margin-bottom: 8px;
}

.wf-node .label {
  font-weight: 850;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.wf-node .meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.wf-node .run-dot {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #c8b8a3;
  box-shadow: 0 0 0 3px rgba(200, 184, 163, 0.18);
}

.wf-node[data-run-status="pending"] {
  opacity: 0.74;
}

.wf-node[data-run-status="running"] {
  transform: translateY(-2px);
  border-color: #2563eb;
  box-shadow: 0 18px 36px rgba(37, 99, 235, 0.22);
}

.wf-node[data-run-status="running"] .run-dot {
  background: #2563eb;
  animation: pulse 900ms infinite;
}

.wf-node[data-run-status="completed"] {
  border-color: #16a34a;
  background: #f3fff7;
}

.wf-node[data-run-status="completed"] .run-dot {
  background: #16a34a;
}

.wf-node[data-run-status="failed"] {
  border-color: #dc2626;
  background: #fff1f2;
}

.wf-node[data-run-status="failed"] .run-dot {
  background: #dc2626;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(37, 99, 235, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

.wf-node[data-action-type="callApi"] .type {
  background: #e5efff;
  color: #1d4ed8;
}

.wf-node[data-action-type="activity"] .type,
.wf-node[data-action-type="goBack"] .type {
  background: #e7f8ef;
  color: #08764f;
}

.wf-node[data-action-type="condition"] .type {
  background: #fff6d6;
  color: #946200;
}

.wf-node[data-action-type="workqueue"] .type,
.wf-node[data-action-type="scheduler"] .type {
  background: #ede9fe;
  color: #6d28d9;
}

.wf-node[data-action-type="command"] .type {
  background: #ffe4e6;
  color: #be123c;
}

.output-card {
  min-height: 310px;
}

.output-card.small {
  min-height: 210px;
}

pre,
#jsonOutput {
  min-height: 220px;
  max-height: 310px;
  overflow: auto;
  white-space: pre;
  border-radius: 12px;
  border: 1px solid #1e293b;
  background: #111827;
  color: #e5edf9;
  padding: 12px;
  font: 12px/1.55 "Cascadia Mono", Consolas, monospace;
}

#jsonOutput {
  min-height: 160px;
  max-height: 240px;
  resize: vertical;
}

#traceOutput {
  min-height: 140px;
  max-height: 210px;
}

.runtime-status {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f5eadc;
  color: #8a4f21;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.runtime-status[data-status="running"] {
  background: #dbeafe;
  color: #1d4ed8;
}

.runtime-status[data-status="completed"] {
  background: #dcfce7;
  color: #15803d;
}

.runtime-status[data-status="failed"] {
  background: #fee2e2;
  color: #b91c1c;
}

.runtime-cards {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.runtime-card {
  border: 1px solid #e0d4c6;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.runtime-card[data-status="running"] {
  border-color: #93c5fd;
  background: #eff6ff;
}

.runtime-card[data-status="completed"] {
  border-color: #86efac;
  background: #f0fdf4;
}

.runtime-card[data-status="failed"] {
  border-color: #fecaca;
  background: #fff1f2;
}

.runtime-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.runtime-card-head strong {
  overflow-wrap: anywhere;
}

.runtime-card-head span,
.runtime-card-type,
.meter-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.runtime-card-type {
  margin-top: 2px;
}

.meter-label {
  margin-top: 8px;
}

.meter {
  height: 7px;
  background: #eadfd1;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 5px;
}

.meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #16a34a);
  border-radius: inherit;
  transition: width 180ms ease;
}

.tick-row {
  display: flex;
  gap: 5px;
  margin-top: 7px;
}

.tick-row span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #d6c8b5;
}

.tick-row span.running {
  background: #2563eb;
  animation: pulse 900ms infinite;
}

.tick-row span.done {
  background: #16a34a;
}

.empty.compact {
  padding: 10px;
  font-size: 12px;
}

@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 280px minmax(480px, 1fr);
  }

  .right-panel {
    display: none;
  }
}
