/* =========================
   cmd / net / server theme
   ========================= */

:root{
  --bg0: #050607;
  --bg1: #0b0e10;
  --panel: rgba(10, 12, 14, .72);
  --panel2: rgba(10, 12, 14, .88);
  --line: rgba(255,255,255,.08);

  --txt: rgba(235, 245, 240, .92);
  --muted: rgba(235, 245, 240, .62);
  --dim: rgba(235, 245, 240, .42);

  --green: rgba(0, 255, 140, .85);
  --greenSoft: rgba(0, 255, 140, .18);
  --blue: rgba(0, 160, 255, .75);
  --red: rgba(255, 80, 95, .85);

  --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%; }
body{
  margin:0;
  color: var(--txt);
  font-family: var(--sans);
  overflow:hidden; /* IMPORTANT: no body scrolling */
  background: var(--bg0);
}

/* fixed background layer (doesn't scroll) */
.bg{
  position:fixed;
  inset:0;
  z-index:-1;
  background:
    radial-gradient(1200px 800px at 20% 12%, rgba(0,255,140,.10), transparent 60%),
    radial-gradient(900px 700px at 78% 28%, rgba(0,160,255,.10), transparent 60%),
    radial-gradient(800px 600px at 60% 86%, rgba(255,80,95,.06), transparent 60%),
    linear-gradient(180deg, #050607 0%, #0a0d10 60%, #07090b 100%);
}

/* app shell */
.app{
  height:100vh;
  display:flex;
  flex-direction:column;
  min-width:0;
}

/* header */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:18px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  backdrop-filter: blur(8px);
}

.brand{ min-width:0; }
.brandTitle{
  font-size:20px;
  font-weight:800;
  letter-spacing:.2px;
}
.brandSub{
  font-size:12px;
  color: var(--muted);
  margin-top:2px;
}

.topbarActions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.sep{
  width:1px;
  height:22px;
  background: var(--line);
  margin:0 2px;
}

/* layout */
.layout{
  flex:1;
  display:grid;
  grid-template-columns: 340px minmax(520px, 1fr) 360px;
  gap:14px;
  padding:14px;
  min-width:0;
  overflow:hidden; /* IMPORTANT: prevent sideways scroll */
}

/* responsive */
@media (max-width: 1200px){
  .layout{ grid-template-columns: 320px minmax(420px, 1fr); }
  .right{ display:none; }
}
@media (max-width: 900px){
  .layout{ grid-template-columns: 1fr; }
  .left{ order:2; }
  .center{ order:1; }
  .right{ order:3; display:block; }
}

/* panels */
.panel{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  overflow:hidden;
  min-width:0; /* IMPORTANT: fix “goes wide” bug */
}

.panelHead{
  padding:12px 14px;
  border-bottom: 1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
}
.panelHead.tight{ padding:10px 14px; }
.panelTitle{ font-weight:800; letter-spacing:.2px; }
.panelHint{ color: var(--muted); font-size:12px; }

.divider{
  height:1px;
  background: var(--line);
  margin:12px 0;
}

/* controls */
.btn{
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: var(--txt);
  padding:9px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight:700;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}
.btnLink{
  border-color: rgba(255,247,79,.35);
  background: rgba(255,247,79,.10);
  text-decoration: none;
  transition: all .35s ease-in-out;
}
.btnLink:hover{
  border-color: rgba(255,247,79,.85);
  background: rgba(255,167,29,.12);
  letter-spacing: 1px;
  transition: all .35s ease-in-out;
}
.btn:hover{
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.16);
}
.btn:active{ transform: translateY(1px); }
.btnGood{
  border-color: rgba(0,255,140,.28);
  background: rgba(0,255,140,.08);
}
.btnBad{
  border-color: rgba(255,80,95,.24);
  background: rgba(255,80,95,.07);
}

.input{
  width:100%;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.24);
  color: var(--txt);
  padding:9px 10px;
  border-radius: 12px;
  outline:none;
}
.input:focus{
  border-color: rgba(0,160,255,.35);
  box-shadow: 0 0 0 3px rgba(0,160,255,.10);
}

.mono{ font-family: var(--mono); }
.dim{ color: var(--dim); }
.status{ color: var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* library tiles */
.libGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  padding:12px 14px 6px;
}
.tile{
  text-align:left;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
  border-radius: 14px;
  padding:10px 10px;
  cursor:pointer;
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
  min-width:0;
}
.tile:hover{
  border-color: rgba(0,255,140,.25);
  background: rgba(0,255,140,.06);
}
.tile:active{ transform: translateY(1px); }
.tileTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.tileSub{ margin-top:8px; color: var(--muted); font-size:12px; }

.chip{
  font-family: var(--mono);
  font-weight:800;
  font-size:12px;
  padding:4px 8px;
  border-radius: 999px;
  border:1px solid rgba(0,255,140,.22);
  background: rgba(0,255,140,.07);
  letter-spacing:.5px;
}

/* node list */
.list{
  padding:10px 10px 14px;
  overflow:auto;
  height: calc(100% - 420px);
  min-height: 180px;
}
.item{
  width:100%;
  text-align:left;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.18);
  border-radius: 14px;
  padding:10px 12px;
  cursor:pointer;
  display:flex;
  flex-direction:column;
  gap:4px;
  margin-bottom:10px;
}
.item:hover{ border-color: rgba(0,160,255,.20); }
.item.active{
  border-color: rgba(0,255,140,.35);
  box-shadow: 0 0 0 3px rgba(0,255,140,.08);
}
.itemRow{
  display:flex;
  justify-content:space-between;
  gap:10px;
  min-width:0;
}
.itemTitle{ font-weight:800; }
.itemMeta{ font-family: var(--mono); color: var(--muted); font-size:12px; }

/* canvas */
.canvasWrap{
  position:relative;
  height: calc(100% - 52px);
  min-height: 520px;
  background: rgba(0,0,0,.18);
  border-top: 1px solid rgba(255,255,255,.04);
  overflow:hidden;
  min-width:0;
}

.gridOverlay{
  position:absolute; inset:0;
  background:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: .08;
  pointer-events:none;
}

.viewport{
  position:absolute;
  inset:0;
  overflow:hidden;
  cursor: default;
}

.world{
  position:absolute;
  left:0; top:0;
  transform-origin: 0 0;
  will-change: transform;
}

.wires{
  position:absolute;
  left:0; top:0;
  width:4000px; height:4000px; /* huge working area */
  overflow:visible;
  pointer-events:auto;
}

.nodes{
  position:absolute;
  left:0; top:0;
  width:4000px; height:4000px; /* same */
}

/* node cards */
.node{
  position:absolute;
  width:240px;
  border-radius: 14px;
  border:1px solid rgba(0,255,140,.22);
  background: linear-gradient(180deg, rgba(10,12,14,.92), rgba(6,8,10,.92));
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 18px 40px rgba(0,0,0,.45);
  color: var(--txt);
  user-select:none;
}
.node.selected{
  border-color: rgba(0,160,255,.45);
  box-shadow: 0 0 0 3px rgba(0,160,255,.12), 0 18px 40px rgba(0,0,0,.45);
}

.nodeHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.nodeType{
  font-family: var(--mono);
  font-weight:900;
  letter-spacing:.6px;
  font-size:12px;
  color: rgba(0,255,140,.92);
}
.nodeId{
  font-family: var(--mono);
  font-size:12px;
  color: var(--muted);
}

.nodeBody{
  padding:10px 12px;
  font-size:12px;
  color: var(--muted);
  line-height:1.35;
  min-height: 44px;
}

.portRow{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  padding:10px 12px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.port{
  width:32px;
  height:28px;
  border-radius: 10px;
  border:1px solid rgba(0,255,140,.28);
  background: rgba(0,255,140,.08);
  color: rgba(220,255,235,.95);
  font-family: var(--mono);
  font-weight:900;
  font-size:12px;
  display:grid;
  place-items:center;
  cursor: crosshair;
}
.port:hover{ border-color: rgba(0,160,255,.35); }
.port.armed{
  outline: 2px solid rgba(0,160,255,.85);
  outline-offset: 2px;
}

/* wire styles */
.wire{
  stroke: rgba(0,255,140,.72);
  stroke-width: 2.2;
  stroke-linecap: round;
}
.wireHit{
  stroke: rgba(0,0,0,0);
  stroke-width: 12;
  stroke-linecap: round;
  cursor: pointer;
}
.wireSelected{
  stroke: rgba(0,160,255,.86);
  stroke-width: 2.8;
}
.wireGhost{
  stroke: rgba(0,160,255,.65);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  stroke-linecap: round;
}

.canvasHelp{
  position:absolute;
  left:12px;
  bottom:12px;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.28);
  color: var(--muted);
  backdrop-filter: blur(8px);
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  max-width: calc(100% - 24px);
}

.kbd{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
  padding:2px 8px;
  border-radius: 999px;
}
.dot{ opacity:.55; }

/* inspector */
.inspector{
  padding:12px 14px 14px;
  overflow:auto;
  height: calc(100% - 240px);
  min-height: 240px;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-bottom:12px;
}
.label{
  font-size:12px;
  color: var(--muted);
}
.row{
  display:flex;
  gap:10px;
}
.row > *{ flex:1; min-width:0; }

.badge{
  font-family: var(--mono);
  font-weight:900;
  font-size:12px;
  padding:6px 10px;
  border-radius: 999px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: var(--txt);
  display:inline-flex;
  align-items:center;
  gap:8px;
}

.emptyState{
  padding:12px;
  border:1px dashed rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(0,0,0,.15);
}

/* help box */
.helpBox{
  padding:12px 14px 16px;
}
.helpTitle{
  font-weight:900;
  margin-bottom:6px;
}
.helpText{ color: var(--muted); font-size:13px; line-height:1.45; }
.path{
  margin-top:8px;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid rgba(0,255,140,.18);
  background: rgba(0,255,140,.06);
  color: rgba(220,255,235,.95);
  overflow:auto;
}
.helpSmall{ margin-top:10px; color: var(--dim); font-size:12px; }

/* footer */
.footer{
  padding:10px 14px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size:12px;
  text-align:center;
  background: rgba(0,0,0,.18);
}

/* nicer scrollbars */
*::-webkit-scrollbar{ width: 12px; height: 12px; }
*::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.10);
  border: 3px solid rgba(0,0,0,0);
  background-clip: padding-box;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover{ background: rgba(255,255,255,.14); background-clip: padding-box; }
