:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f2330;
  --border: #2c3140;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --accent: #5b8cff;
  --danger: #ff6b6b;
  --ok: #43c98f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

header.topbar h1 {
  font-size: 16px;
  margin: 0;
}

header.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 16px;
  font-size: 13px;
}

header.topbar nav a:hover { color: var(--text); }

main { padding: 20px; }

button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}

button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

th { color: var(--muted); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
}
.badge.success { background: rgba(67,201,143,0.15); color: var(--ok); }
.badge.failed { background: rgba(255,107,107,0.15); color: var(--danger); }
.badge.skipped { background: rgba(154,163,178,0.2); color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.errors { color: var(--danger); font-size: 13px; white-space: pre-line; }
.warnings { color: #e0b34d; font-size: 13px; white-space: pre-line; }
.hint { color: var(--muted); font-size: 12px; }

code {
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ===== builder canvas ===== */

.builder-layout {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 12px;
  height: calc(100vh - 110px);
}

.palette {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-y: auto;
}

.palette h3 { margin-top: 0; font-size: 13px; color: var(--muted); }

.palette-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 13px;
}
.palette-item:hover { border-color: var(--accent); }
.palette-item .category { display: block; font-size: 10px; color: var(--muted); }

#canvas-wrap {
  position: relative;
  overflow: auto;
  background:
    linear-gradient(var(--panel-2) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--panel-2) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

#canvas {
  position: relative;
  width: 2000px;
  height: 1400px;
}

#edge-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.node-card {
  position: absolute;
  width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  user-select: none;
}

.node-card .node-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
}

.node-card .node-head .close { cursor: pointer; color: var(--muted); }
.node-card .node-head .close:hover { color: var(--danger); }

.node-body { padding: 8px 10px; font-size: 12px; }
.node-body label { display: block; margin-bottom: 6px; color: var(--muted); }
.node-body input, .node-body select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  margin-top: 2px;
}

.port {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: crosshair;
}
.port.input { left: -7px; background: var(--muted); }
.port.output { right: -7px; }
.port.output.true { background: var(--ok); }
.port.output.false { background: var(--danger); }
.port-label {
  position: absolute;
  font-size: 9px;
  color: var(--muted);
}

.side-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-y: auto;
}

.side-panel h3 { font-size: 13px; color: var(--muted); margin-top: 0; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input { width: 100%; padding: 6px 8px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; }
