:root{
  --bg:#0b0d12;
  --panel:#0f1420;
  --panel2:#0c111b;
  --card:#11182a;
  --line:#1b2740;
  --text:#e9eefc;
  --muted:#9fb0d6;
  --accent:#7aa2ff;
  --good:#20d17a;
  --bad:#ff4d6d;
  --warn:#ffcc66;
  --shadow: 0 14px 50px rgba(0,0,0,.55);
  --radius:16px;
  --radius2:12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; background:var(--bg); color:var(--text); font-family:var(--sans); }

#app{ height:100%; display:flex; flex-direction:column; }

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; border-bottom:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.03), transparent);
}

.brand{ display:flex; gap:12px; align-items:center; }
.logo{
  width:40px; height:40px; display:grid; place-items:center;
  border-radius:12px; background: radial-gradient(circle at 30% 30%, rgba(122,162,255,.6), rgba(122,162,255,.12));
  border:1px solid rgba(122,162,255,.25);
  font-weight:800;
}
.title .name{ font-size:14px; font-weight:800; letter-spacing:.2px; }
.title .sub{ font-size:12px; color:var(--muted); }

.actions{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.divider{ width:1px; height:26px; background:var(--line); margin:0 6px; }

.btn{
  position:relative;
  padding:9px 12px;
  border-radius:12px;
  border:1px solid rgba(122,162,255,.22);
  background: rgba(122,162,255,.14);
  color:var(--text);
  cursor:pointer;
  font-weight:700;
  font-size:12px;
  letter-spacing:.2px;
  transition: transform .08s ease, background .15s ease, border .15s ease;
  user-select:none;
}
.btn:hover{ background: rgba(122,162,255,.22); }
.btn:active{ transform: translateY(1px); }
.btn.ghost{ background: rgba(255,255,255,.03); border:1px solid var(--line); }
.btn.ghost:hover{ background: rgba(255,255,255,.06); }

.main{
  flex:1;
  display:grid;
  grid-template-columns: 310px 1fr 310px;
  gap:12px;
  padding:12px;
  min-height:0;
}

.panel{
  min-height:0;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.panelTitle{
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  font-weight:900;
  letter-spacing:.2px;
  font-size:13px;
  background: rgba(0,0,0,.15);
}
.panelBody{ padding:12px 14px; overflow:auto; min-height:0; }

.center{ display:flex; flex-direction:column; gap:12px; min-height:0; }
.canvasWrap{
  position:relative;
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  min-height:280px;
}
#viewer{ width:100%; height:360px; display:block; background:#05070c; }
.viewerHUD{
  position:absolute; inset:0; pointer-events:none;
  display:flex; justify-content:space-between; align-items:flex-start;
  padding:10px 12px;
  font-size:12px; color:var(--muted);
}
.hudLeft{ font-weight:800; color:var(--text); opacity:.9; }
.hudRight{ font-family:var(--mono); opacity:.85; }

.graphWrap{
  position:relative;
  flex:1;
  min-height:0;
  background:linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.graph{
  position:absolute; inset:0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.06) 1px, transparent 0);
  background-size: 22px 22px;
}
.wires{
  position:absolute; inset:0;
  pointer-events:none;
}

.node{
  position:absolute;
  width:240px;
  border-radius: 16px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(17,24,42,.92);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  overflow:hidden;
  user-select:none;
}
.nodeHeader{
  display:flex; justify-content:space-between; align-items:center;
  padding:10px 12px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.12);
}
.nodeTitle{
  font-size:12px;
  font-weight:900;
  letter-spacing:.2px;
}
.nodeType{
  font-size:11px;
  color:var(--muted);
  font-family:var(--mono);
}
.nodeBody{
  padding:10px 12px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
.ports{ display:flex; flex-direction:column; gap:8px; }
.port{
  display:flex; align-items:center; gap:8px;
  font-size:12px;
  color:var(--muted);
}
.portDot{
  width:12px; height:12px; border-radius:50%;
  border:1px solid rgba(255,255,255,.2);
  background: rgba(122,162,255,.22);
  box-shadow: 0 0 0 4px rgba(122,162,255,.08);
  cursor:pointer;
  pointer-events:auto;
}
.portDot.out{ background: rgba(32,209,122,.22); box-shadow:0 0 0 4px rgba(32,209,122,.08); }
.portDot.in{ background: rgba(122,162,255,.22); }
.node.selected{ outline:2px solid rgba(122,162,255,.55); }

.kv{
  display:flex; flex-direction:column; gap:6px;
  background: rgba(0,0,0,.18);
  border:1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding:10px;
}
.kv label{ font-size:11px; color:var(--muted); }
.kv input[type="range"]{ width:100%; }
.kv input[type="number"], .kv input[type="text"], .kv select{
  width:100%;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  color:var(--text);
  padding:8px 10px;
  outline:none;
}
.kv input[type="color"]{
  width:100%;
  height:34px;
  border:none;
  background:transparent;
}

.assets{
  display:flex; flex-direction:column; gap:10px;
}
.assetCard{
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.18);
  border-radius: 14px;
  padding:10px;
  display:flex;
  gap:10px;
  align-items:center;
}
.assetThumb{
  width:52px; height:36px;
  border-radius: 10px;
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.08);
  overflow:hidden;
}
.assetThumb img{ width:100%; height:100%; object-fit:cover; display:block; }
.assetMeta{ flex:1; min-width:0; }
.assetName{ font-weight:900; font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.assetInfo{ font-size:11px; color:var(--muted); font-family:var(--mono); }

.bottombar{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px;
  border-top:1px solid var(--line);
  color:var(--muted);
  font-size:12px;
  background: rgba(0,0,0,.15);
}
.status{ display:flex; align-items:center; gap:8px; }
.dot{ width:10px; height:10px; border-radius:50%; background:var(--good); box-shadow:0 0 0 4px rgba(32,209,122,.12); }
