:root {
  --bg: #070914;
  --panel: rgba(255, 255, 255, .075);
  --panel-strong: rgba(255, 255, 255, .12);
  --line: rgba(255, 255, 255, .14);
  --line-strong: rgba(255, 255, 255, .26);
  --text: #f6f8ff;
  --muted: rgba(246, 248, 255, .66);
  --soft: rgba(246, 248, 255, .46);
  --accent: #bfe5ff;
  --accent-2: #ffd1fb;
  --ok: #91ffc2;
  --warn: #ffd58a;
  --danger: #ff9a9a;
  --node-w: 280px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% -8%, rgba(67, 152, 255, .38), transparent 32%),
    radial-gradient(circle at 100% 5%, rgba(255, 119, 241, .28), transparent 34%),
    radial-gradient(circle at 70% 100%, rgba(147, 237, 255, .12), transparent 36%),
    linear-gradient(160deg, #111632 0%, #080a16 55%, #050711 100%);
  overflow: hidden;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.glow { position: fixed; border-radius: 999px; filter: blur(80px); pointer-events: none; opacity: .45; }
.glow-a { width: 360px; height: 360px; left: -100px; top: 18%; background: #3d9dff; }
.glow-b { width: 360px; height: 360px; right: -120px; top: -110px; background: #fd79f5; }
.glow-c { width: 270px; height: 270px; right: 24%; bottom: -150px; background: #9ee7ff; opacity: .22; }
.app { position: relative; z-index: 1; height: 100vh; display: grid; grid-template-rows: auto 1fr; padding: 14px; gap: 14px; }
.topbar, .panel {
  background: linear-gradient(150deg, rgba(255,255,255,.105), rgba(255,255,255,.055));
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 24px 90px rgba(0,0,0,.35);
  backdrop-filter: blur(24px);
}
.topbar { min-height: 76px; display: flex; align-items: center; gap: 18px; padding: 14px 18px; }
.brand { display: flex; align-items: center; gap: 13px; min-width: 270px; }
.mark { width: 48px; height: 48px; border-radius: 17px; display: grid; place-items: center; color: #0b1225; font-weight: 1000; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 16px 45px rgba(191,229,255,.22); }
.eyebrow { margin: 0 0 4px; color: var(--accent); letter-spacing: .18em; font-size: 11px; font-weight: 850; }
h1, h2, h3 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }
p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 13px; }
.token-box { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 560px; }
.token-label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.status-box { margin-left: auto; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; min-width: 170px; align-items: flex-end; }
.ok { color: var(--ok); }
.err { color: var(--danger); }
.warn { color: var(--warn); }
.muted { color: var(--muted); }
.layout { min-height: 0; display: grid; grid-template-columns: 280px 1fr 350px; gap: 14px; }
.panel { min-height: 0; overflow: hidden; }
.palette, .inspector { padding: 16px; overflow: auto; scrollbar-width: thin; }
.canvas-panel { display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.panel-head, .canvas-toolbar, .selected-title, .output-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.canvas-toolbar { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.group { background: rgba(0,0,0,.16); border: 1px solid var(--line); border-radius: 20px; padding: 13px; margin-top: 12px; }
.group h3 { margin-bottom: 10px; color: rgba(255,255,255,.92); }
.help p + p { margin-top: 7px; }
.key-group { max-height: 300px; overflow: auto; }
.key-list { display: grid; gap: 8px; }
.key-row { padding: 9px 10px; border-radius: 15px; background: rgba(255,255,255,.055); border: 1px solid var(--line); display: grid; gap: 4px; }
.key-row code { color: var(--accent); font-size: 11px; }
.key-row small { color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.key-row.healthy { border-color: rgba(145,255,194,.22); }
.key-row.bad { border-color: rgba(255,154,154,.32); }
.node-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
button {
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  color: #11182c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 900;
  transition: transform .15s ease, opacity .15s ease, border-color .15s ease;
}
button:hover { transform: translateY(-1px); }
button:disabled { opacity: .55; transform: none; cursor: not-allowed; }
.ghost, .small.ghost, .template-btn, .add-node {
  color: var(--text);
  background: rgba(255,255,255,.075);
  border: 1px solid var(--line);
}
.template-btn { width: 100%; text-align: left; margin-top: 8px; }
.add-node { min-height: 42px; }
.primary { background: linear-gradient(135deg, rgba(191,229,255,.98), rgba(255,209,251,.92)); color: #10182c; }
.danger { color: var(--danger); }
.small { padding: 7px 9px; border-radius: 999px; font-size: 12px; }
input, textarea, select {
  width: 100%;
  border: 1px solid rgba(255,255,255,.16);
  color: var(--text);
  background: rgba(0,0,0,.22);
  border-radius: 14px;
  padding: 10px 11px;
  outline: none;
}
textarea { resize: vertical; min-height: 54px; }
input:focus, textarea:focus, select:focus { border-color: rgba(191,229,255,.72); box-shadow: 0 0 0 4px rgba(191,229,255,.10); }
label { display: block; color: var(--muted); font-size: 12px; margin: 12px 0 6px; }
select option { color: var(--text); background: #11162a; }
.flow-viewport { position: relative; min-height: 0; overflow: hidden; background: rgba(0,0,0,.12); cursor: grab; }
.flow-viewport.panning { cursor: grabbing; }
.flow-viewport::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(191,229,255,.16), transparent 42%);
  background-size: 34px 34px, 34px 34px, 100% 100%;
  pointer-events: none;
}
.flow-scene { position: absolute; left: 0; top: 0; width: 3000px; height: 2000px; transform-origin: 0 0; }
.edges { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.edge-path { fill: none; stroke: rgba(191,229,255,.66); stroke-width: 3; filter: drop-shadow(0 0 8px rgba(191,229,255,.25)); }
.edge-path.active { stroke: rgba(255,209,251,.9); }
.nodes-layer { position: absolute; inset: 0; }
.node {
  position: absolute; width: var(--node-w); min-height: 145px;
  border-radius: 22px; border: 1px solid var(--line-strong);
  background: linear-gradient(150deg, rgba(24,30,57,.94), rgba(13,16,31,.9));
  box-shadow: 0 24px 70px rgba(0,0,0,.34);
  backdrop-filter: blur(18px);
  user-select: none;
}
.node.selected { border-color: rgba(255,209,251,.72); box-shadow: 0 0 0 4px rgba(255,209,251,.10), 0 24px 70px rgba(0,0,0,.34); }
.node.running { border-color: rgba(191,229,255,.74); }
.node.ok { border-color: rgba(145,255,194,.58); }
.node.error { border-color: rgba(255,154,154,.7); }
.node-head { padding: 12px 12px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); cursor: grab; }
.node-head:active { cursor: grabbing; }
.node-icon { width: 38px; height: 38px; border-radius: 15px; display: grid; place-items: center; font-weight: 1000; color: #11182c; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex: 0 0 auto; }
.node-title { min-width: 0; flex: 1; }
.node-title b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-title small { display: block; color: var(--soft); margin-top: 2px; font-size: 11px; }
.node-body { padding: 12px; }
.node-summary { color: var(--muted); font-size: 12px; line-height: 1.5; min-height: 38px; word-break: break-word; }
.node-status { margin-top: 10px; padding: 7px 9px; border-radius: 999px; background: rgba(255,255,255,.07); border: 1px solid var(--line); color: var(--soft); font-size: 11px; display: inline-flex; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-status.running { color: var(--accent); }
.node-status.ok { color: var(--ok); }
.node-status.error { color: var(--danger); }
.port { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.64); background: #10162a; box-shadow: 0 0 0 5px rgba(191,229,255,.08); cursor: crosshair; }
.port:hover, .port.pending { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: #fff; }
.port.in { left: -9px; top: 60px; }
.port.out { right: -9px; top: 60px; }
.zoom-badge { position: absolute; right: 14px; bottom: 14px; padding: 8px 10px; border-radius: 999px; background: rgba(0,0,0,.42); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.run-log { padding: 12px 14px; border-top: 1px solid var(--line); background: rgba(0,0,0,.16); max-height: 150px; }
.run-log div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#runState { color: var(--soft); font-size: 12px; }
.run-log pre { margin: 8px 0 0; white-space: pre-wrap; max-height: 82px; overflow: auto; color: var(--soft); font-size: 12px; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.empty-inspector { text-align: center; padding: 42px 10px; }
.empty-icon { width: 58px; height: 58px; border-radius: 22px; margin: 0 auto 16px; display: grid; place-items: center; color: #10182c; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: 24px; }
.selected-title { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.type-pill { display: inline-flex; margin-bottom: 5px; padding: 4px 8px; border-radius: 999px; color: var(--accent); background: rgba(255,255,255,.075); border: 1px solid var(--line); font-size: 11px; }
.field-row { margin-bottom: 10px; }
.field-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; }
.checkbox-label input { width: auto; }
.output-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.node-output { min-height: 130px; max-height: 360px; overflow: auto; padding: 12px; border-radius: 16px; background: rgba(0,0,0,.22); border: 1px solid var(--line); color: var(--muted); white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.58; }
.preview-img, .preview-video { width: 100%; border-radius: 16px; border: 1px solid var(--line); display: block; background: rgba(0,0,0,.2); margin-top: 10px; }
.output-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.output-links a { padding: 7px 9px; border-radius: 999px; background: rgba(255,255,255,.08); border: 1px solid var(--line); font-size: 12px; color: var(--text); }
@media (max-width: 1200px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .topbar { flex-wrap: wrap; }
  .layout { grid-template-columns: 1fr; }
  .palette, .inspector { max-height: none; }
  .canvas-panel { min-height: 720px; }
}
@media (max-width: 720px) {
  .app { padding: 8px; }
  .topbar, .panel { border-radius: 22px; }
  .brand { min-width: 0; }
  .token-box, .status-box { width: 100%; max-width: none; align-items: stretch; }
  .status-box { align-items: flex-start; }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions button { flex: 1 1 auto; }
  .node-buttons { grid-template-columns: 1fr; }
}


.node-media { margin-top: 10px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: rgba(0,0,0,.22); max-height: 128px; }
.node-media img, .node-media video { display: block; width: 100%; max-height: 128px; object-fit: cover; }
.video-thumb { position: relative; min-height: 96px; display: grid; place-items: center; }
.video-thumb span { position: absolute; left: 10px; bottom: 9px; padding: 5px 8px; border-radius: 999px; background: rgba(0,0,0,.55); color: var(--text); font-size: 11px; border: 1px solid var(--line); }
.mini-raw { margin: 10px 0 0; white-space: pre-wrap; color: var(--soft); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
