:root {
  --bg: #0b1020;
  --panel: #121a2f;
  --panel2: #182240;
  --line: #2a3a66;
  --text: #e8eefc;
  --muted: #8fa0c8;
  --accent: #5b8cff;
  --accent2: #3dd6c6;
  --warn: #ffb020;
  --danger: #ff6b7a;
  --ok: #3ecf8e;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2a55 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 0%, #123a3a 0%, transparent 50%),
              var(--bg);
}
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.18;
  background-image:
    linear-gradient(rgba(91,140,255,0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91,140,255,0.12) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 20px 28px; position: relative; z-index: 1;
}
.brand { display: flex; gap: 14px; align-items: center; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #061018; font-size: 22px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(91,140,255,0.35);
}
h1 { margin: 0; font-size: 1.45rem; letter-spacing: 0.02em; }
.tag { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  font-size: 0.75rem; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(18,26,47,0.8);
}
.badge.live { border-color: var(--ok); color: var(--ok); }
.badge.demo { border-color: var(--warn); color: var(--warn); }
.badge.muted { color: var(--muted); }
.layout {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 18px;
  padding: 0 28px 28px; position: relative; z-index: 1;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }
.panel {
  background: linear-gradient(180deg, rgba(24,34,64,0.95), rgba(18,26,47,0.92));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: 0 12px 40px rgba(0,0,0,0.28);
}
.panel h2 { margin: 0 0 12px; font-size: 1.05rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chips button {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 999px; padding: 7px 12px; cursor: pointer; font-size: 0.8rem;
}
.chips button:hover { border-color: var(--accent); color: #fff; }
textarea, select, button.primary {
  font: inherit; color: var(--text);
}
textarea {
  width: 100%; resize: vertical; min-height: 84px;
  background: #0d1428; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; outline: none;
}
textarea:focus { border-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
select {
  background: #0d1428; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-width: 140px;
}
button.primary {
  background: linear-gradient(135deg, var(--accent), #4b6fff);
  border: none; border-radius: 10px; padding: 10px 18px; font-weight: 600;
  cursor: pointer; box-shadow: 0 6px 18px rgba(91,140,255,0.35);
}
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.6; cursor: wait; }
.answer {
  margin-top: 14px; padding: 14px; border-radius: 10px;
  background: #0d1428; border: 1px solid var(--line);
  white-space: pre-wrap; line-height: 1.45; min-height: 72px;
}
.answer.empty { color: var(--muted); }
.meta { color: var(--muted); font-size: 0.8rem; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 10px; }
#canvasWrap {
  background: #0a1224; border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; min-height: 320px;
}
#graphSvg { width: 100%; height: 360px; display: block; }
.node circle { stroke-width: 2; }
.node text { fill: var(--text); font-size: 11px; text-anchor: middle; font-family: var(--font); }
.edge { stroke: #4a5f99; stroke-width: 1.6; fill: none; }
.edge-label { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.raw {
  margin: 12px 0 0; max-height: 180px; overflow: auto;
  background: #0a1224; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; font-family: var(--mono); font-size: 11px; color: #b7c6ef;
}
footer {
  text-align: center; color: var(--muted); padding: 8px 16px 28px;
  font-size: 0.85rem; position: relative; z-index: 1;
}
footer a { color: var(--accent2); }
