:root {
  --bg: #07111f;
  --panel: rgba(13, 27, 47, 0.92);
  --text: #eaf6ff;
  --muted: #91a8bd;
  --border: rgba(255,255,255,0.12);
  --accent: #66e3ff;
  --accent2: #a78bfa;
  --green: #64f4ac;
  --red: #ff8fab;
  --warn: #ffd166;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  height: 72px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(7,17,31,0.9);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h1, h2 { margin: 0; }
h1 { font-size: 24px; letter-spacing: -0.04em; }
h2 { font-size: 15px; margin: 18px 0 12px; }
h2:first-child { margin-top: 0; }
span, .muted { color: var(--muted); font-size: 13px; }

button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
}

button:hover { border-color: rgba(102,227,255,0.6); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

#runBtn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #04101b;
  border: none;
}

.layout {
  height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 280px 1fr 390px;
}

.sidebar, .properties {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px;
  overflow: auto;
  z-index: 5;
}

.properties {
  border-right: none;
  border-left: 1px solid var(--border);
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  cursor: grab;
  background:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    radial-gradient(circle at top left, rgba(102,227,255,0.09), transparent 30%),
    #081626;
  background-size: 28px 28px, 28px 28px, auto, auto;
}

.canvas-wrap.panning { cursor: grabbing; }

.workspace {
  position: absolute;
  left: 0;
  top: 0;
  width: 2600px;
  height: 1200px;
  transform-origin: 0 0;
}

.edges {
  position: absolute;
  inset: 0;
  width: 2600px;
  height: 1200px;
  pointer-events: none;
  z-index: 1;
}

.nodes-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.block-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(255,255,255,0.04);
}

.block-item strong {
  display: block;
  margin-bottom: 5px;
}

.category {
  margin: 18px 0 8px;
  color: var(--accent);
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
}

.node {
  position: absolute;
  width: 210px;
  min-height: 96px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035));
  box-shadow: 0 14px 40px rgba(0,0,0,0.25);
  padding: 12px;
  cursor: grab;
  user-select: none;
}

.node:active { cursor: grabbing; }

.node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(102,227,255,0.14), 0 14px 40px rgba(0,0,0,0.25);
}

.node-title {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 900;
}

.node-type {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}

.port-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

.input-json {
  width: 100%;
  min-height: 150px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #06101d;
  color: #dff8ff;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  resize: vertical;
}

.prop-card, .result-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.04);
  margin-bottom: 12px;
}

.result-card.success {
  border-color: rgba(100,244,172,0.45);
  background: rgba(100,244,172,0.07);
}

.result-card.error {
  border-color: rgba(255,143,171,0.45);
  background: rgba(255,143,171,0.07);
}

.badge {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(102,227,255,0.13);
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  margin: 4px 5px 4px 0;
}

.badge.green {
  background: rgba(100,244,172,0.13);
  color: var(--green);
}

.badge.warn {
  background: rgba(255,209,102,0.14);
  color: var(--warn);
}

.prop-card label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #06101d;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  color: #dff8ff;
  max-height: 300px;
  overflow: auto;
  font-size: 12px;
}

.empty {
  color: var(--muted);
  padding: 14px 0;
}

.openqwl-text {
  min-height: 220px;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Wizard */
.wizard-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}

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

.wizard-card {
  width: min(1180px, 96vw);
  height: min(860px, 96vh);
  max-height: 96vh;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: rgba(13, 27, 47, 0.98);
  box-shadow: 0 28px 90px rgba(0,0,0,0.42);
  display: flex;
  flex-direction: column;
}

.wizard-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.035);
  flex: 0 0 auto;
}

.wizard-header h2 { margin: 0; }

.wizard-body {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.wizard-form, .wizard-output {
  padding: 20px;
  overflow-y: auto;
  min-height: 0;
}

.wizard-form {
  border-right: 1px solid var(--border);
}

.wizard-form label, .wizard-output label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.wizard-form input,
.wizard-form textarea,
.wizard-form select {
  width: 100%;
  background: #081626;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
  font-size: 14px;
}

.wizard-form textarea {
  min-height: 110px;
  resize: vertical;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255,255,255,0.035);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.chip input {
  width: auto;
  margin: 0;
}

.wizard-primary {
  margin-top: 18px;
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #04101b;
  border: none;
}

.wizard-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wizard-form .wizard-primary,
.wizard-output .wizard-primary {
  position: sticky;
  bottom: 0;
  z-index: 3;
  box-shadow: 0 -12px 28px rgba(13,27,47,0.72);
}

.wizard-output h3 {
  margin-top: 0;
}

.ghost-btn {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid var(--border);
}

.wizard-reasoning {
  white-space: pre-wrap;
  line-height: 1.45;
  margin-top: 10px;
}

.result-card.error {
  border-color: rgba(255,143,171,0.45);
  background: rgba(255,143,171,0.07);
}

@media (max-width: 1000px) {
  .wizard-card {
    height: 96vh;
  }

  .wizard-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .wizard-form,
  .wizard-output {
    overflow: visible;
  }

  .wizard-form {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.reasoning {
  white-space: pre-wrap;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 10px;
}

.maxcut-graph {
  width: 100%;
  max-width: 360px;
  display: block;
  margin: 12px auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(0,0,0,0.16);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.legend-dot.set0 { background: var(--accent); }
.legend-dot.set1 { background: var(--accent2); }
.legend-line {
  width: 22px;
  height: 3px;
  display: inline-block;
  background: var(--warn);
  border-radius: 99px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

.result-table th,
.result-table td {
  border-bottom: 1px solid var(--border);
  padding: 7px 6px;
  text-align: left;
}

.result-table th {
  color: var(--accent);
}

.export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
