:root {
  color-scheme: dark;
  --bg: #101318;
  --panel: #15191f;
  --panel-2: #191e25;
  --line: #303741;
  --line-soft: #262c34;
  --text: #e7ebf0;
  --muted: #8d97a4;
  --orange: #ff8c3b;
  --green: #73d69d;
  --blue: #72b6ff;
  --violet: #c694ff;
  --yellow: #efc457;
  --danger: #ff6b72;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font: 12px/1.4 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }

#app { height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) 292px; grid-template-rows: 48px minmax(280px, 58fr) minmax(225px, 42fr) 30px; background: var(--bg); }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 28px; min-width: 0; padding: 0 14px; border-bottom: 1px solid var(--line); background: #14181e; }
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-dot { width: 18px; height: 18px; border-radius: 50% 44% 52% 46%; background: linear-gradient(135deg, #ffad48, #ff6f43); box-shadow: 0 0 22px #ff8c3b55; }
.brand strong { letter-spacing: .01em; }
.subtle { color: var(--muted); }
.version { padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; color: #9ca6b2; font-size: 9px; }
.menu { display: flex; align-items: center; gap: 2px; }
.menu button { padding: 8px 9px; background: transparent; color: #b8c0ca; border-radius: 5px; }
.menu button:hover { background: #222832; color: white; }
.transport { margin-left: auto; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.icon-button, .play-button, .tool-button { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line); background: #202630; }
.icon-button:hover, .tool-button:hover, .tool-button.active { border-color: #52606f; background: #2a323e; color: white; }
.play-button { width: 34px; background: var(--orange); border-color: var(--orange); color: #151515; font-weight: 900; font-size: 14px; }
.play-button:hover { filter: brightness(1.1); }
.quality-label { display: flex; gap: 6px; align-items: center; margin-left: 8px; }
select { border: 1px solid var(--line); background: #1b2028; border-radius: 5px; padding: 4px 7px; outline: none; }
.gpu-status { white-space: nowrap; }
.gpu-status i, .console-title i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #6df0a4; box-shadow: 0 0 8px #6df0a4; }

.viewport-shell { position: relative; min-width: 0; min-height: 0; overflow: hidden; border-bottom: 1px solid var(--line); background: radial-gradient(circle at 50% 35%, #202731 0, #13171c 58%, #0e1115 100%); }
#viewport { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#viewport:active { cursor: grabbing; }
.viewport-toolbar { position: absolute; z-index: 3; left: 12px; top: 12px; display: grid; gap: 7px; }
.viewport-title { position: absolute; top: 12px; left: 64px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.viewport-title span, .viewport-mode span { color: #77818e; font-size: 10px; }
.viewport-mode { position: absolute; right: 12px; top: 12px; text-align: right; font-weight: 700; pointer-events: none; }
.scene-info { position: absolute; left: 15px; bottom: 10px; color: #aeb6c0; font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; pointer-events: none; }

.parameters { grid-column: 2; grid-row: 2 / 4; min-width: 0; overflow: auto; border-left: 1px solid var(--line); background: var(--panel); }
.panel-heading { position: sticky; z-index: 2; top: 0; display: flex; justify-content: space-between; align-items: center; height: 42px; padding: 0 13px; border-bottom: 1px solid var(--line); background: #171b21; }
.panel-heading button { background: transparent; color: var(--muted); font-size: 18px; }
.parameter-empty { padding: 28px 18px; color: var(--muted); text-align: center; }
.param-head { display: flex; gap: 10px; align-items: center; padding: 14px 14px 12px; }
.node-glyph { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: color-mix(in srgb, var(--node-color) 18%, #242a33); color: var(--node-color); font-weight: 900; }
.param-head small { display: block; color: var(--muted); }
.param-section { padding: 0 14px 15px; }
.param-row { display: grid; gap: 5px; margin: 11px 0; color: #aab2bc; }
.param-row input[type="number"], .param-row input[type="text"], .param-row select { width: 100%; height: 31px; border: 1px solid var(--line); border-radius: 5px; background: #11151a; padding: 0 8px; outline: none; }
.param-row input:focus, .param-row select:focus { border-color: var(--orange); }
.param-slider { display: grid; grid-template-columns: minmax(0, 1fr) 74px; gap: 8px; align-items: center; }
.param-slider input[type="range"] { width: 100%; height: 18px; margin: 0; accent-color: var(--orange); cursor: ew-resize; }
.param-vector { margin: 12px 0 15px; color: #aab2bc; }
.param-vector > span { display: block; margin-bottom: 6px; }
.param-vector > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.param-vector label { display: grid; grid-template-columns: 15px minmax(0, 1fr); align-items: center; border: 1px solid var(--line); border-radius: 5px; background: #11151a; overflow: hidden; }
.param-vector b { color: #778391; text-align: center; font-size: 9px; }
.param-vector input { width: 100%; min-width: 0; height: 29px; padding: 0 5px; border: 0; border-left: 1px solid var(--line-soft); outline: none; background: transparent; }
.param-vector label:focus-within { border-color: var(--orange); }
.param-check { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; color: #aab2bc; }
.param-check input { accent-color: var(--orange); }
.node-meta { margin: 4px 14px 14px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; color: #77818e; background: #12161b; font: 9px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

.network-shell { grid-column: 1; position: relative; min-height: 0; display: grid; grid-template-rows: 36px minmax(0, 1fr); background: #12161b; }
.network-header { display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--line); background: #171b21; }
.network-header strong { font-size: 10px; }
.network-header span { margin-left: 8px; color: #727d89; font-size: 10px; }
.network-actions { display: flex; gap: 7px; }
.network-actions button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 5px; background: #202630; color: #b8c0ca; font-size: 10px; }
.network-actions button:hover, .network-actions .accent-button { border-color: #4a5562; color: white; }
.network { position: relative; min-width: 0; min-height: 0; overflow: hidden; outline: none; background-color: #11151a; background-image: radial-gradient(#323944 1px, transparent 1px); background-size: 18px 18px; }
.nodes { position: absolute; inset: 0; transform-origin: 0 0; }
.wires { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.wire { fill: none; stroke-width: 2; opacity: .76; }
.wire.selected { stroke-width: 3; opacity: 1; filter: drop-shadow(0 0 3px currentColor); }
.wire-preview { fill: none; stroke: #dbe3ed; stroke-width: 2; stroke-dasharray: 5 4; opacity: .8; }
.node { --node-color: #9da7b3; position: absolute; z-index: 2; width: 190px; border: 1px solid #3a424e; border-radius: 7px; background: #222831; box-shadow: 0 8px 18px #0005; user-select: none; }
.node.selected { border-color: var(--node-color); box-shadow: 0 0 0 1px color-mix(in srgb, var(--node-color) 35%, transparent), 0 9px 20px #0007; }
.node.displayed { box-shadow: 0 0 0 1px var(--node-color), 0 0 14px color-mix(in srgb, var(--node-color) 35%, transparent); }
.node-header { display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 8px; border-bottom: 1px solid #323a45; cursor: grab; font-weight: 700; }
.node-header:active { cursor: grabbing; }
.node-header .mini-glyph { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 5px; color: #151515; background: var(--node-color); font-size: 9px; font-weight: 900; }
.node-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.display-flag { margin-left: auto; width: 20px; height: 20px; border-radius: 4px; background: transparent; color: #77818d; }
.display-flag:hover, .displayed .display-flag { color: var(--node-color); background: #ffffff0b; }
.node-body { display: grid; grid-template-columns: 1fr 1fr; min-height: 50px; padding: 7px 0; }
.ports { display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.ports.outputs { align-items: flex-end; }
.port { position: relative; display: flex; align-items: center; min-height: 17px; color: #9ca6b2; font-size: 9px; }
.port.input { padding-left: 14px; }
.port.output { padding-right: 14px; justify-content: flex-end; }
.socket { position: absolute; width: 8px; height: 8px; border: 1px solid #aab3be; border-radius: 50%; background: #11151a; transition: transform .12s, box-shadow .12s; }
.input .socket { left: -4px; }
.output .socket { right: -4px; }
.socket.geometry { border-color: #aab6c5; }
.socket.points { border-color: #62d6de; }
.socket.proxy { border-color: var(--green); }
.socket.clusters { border-color: var(--violet); }
.socket.constraints { border-color: var(--yellow); }
.socket.collider { border-color: #ff6e87; }
.socket.simulation { border-color: var(--orange); }
.port.connected .socket, .socket:hover, .socket.hot { transform: scale(1.45); background: currentColor; box-shadow: 0 0 7px currentColor; }
.port.geometry { color: #aab6c5; }.port.points { color: #62d6de; }.port.proxy { color: var(--green); }.port.clusters { color: var(--violet); }.port.constraints { color: var(--yellow); }.port.collider { color: #ff6e87; }.port.simulation { color: var(--orange); }
.connection-hint { position: absolute; z-index: 0; right: 12px; bottom: 8px; color: #5f6975; font-size: 9px; pointer-events: none; }

.console-shell { grid-column: 1 / -1; min-width: 0; border-top: 1px solid var(--line); background: #101318; }
.console-title { width: 100%; height: 29px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: #171b21; color: #aeb7c1; font-size: 10px; }
.console-title > span:first-child { font-weight: 700; color: #dce2e9; }
.console-title b { margin-left: 14px; }
.console-body { position: fixed; z-index: 30; left: 0; right: 0; bottom: 30px; height: 150px; display: none; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 12px; border-top: 1px solid #3a424d; background: #0b0e12ee; backdrop-filter: blur(12px); font: 10px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.console-shell.open .console-body { display: grid; }
#consoleLog { overflow: auto; color: #9ba7b3; }
.log-time { color: #56616e; }.log-node { color: var(--orange); }.log-good { color: var(--green); }.log-warn { color: var(--yellow); }
#clearConsole { align-self: start; padding: 5px 9px; border: 1px solid var(--line); border-radius: 5px; background: #1d232b; color: #9ba5b0; }

.node-menu { position: fixed; z-index: 50; width: 290px; max-height: min(500px, 70vh); overflow: auto; border: 1px solid #424b57; border-radius: 9px; background: #171c23f5; box-shadow: 0 22px 60px #000a; backdrop-filter: blur(18px); }
.node-search { position: sticky; top: 0; z-index: 2; display: flex; gap: 7px; padding: 9px; border-bottom: 1px solid var(--line); background: #171c23; }
.node-search input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 5px; background: #0e1217; padding: 7px 8px; outline: none; }
kbd { align-self: center; padding: 2px 5px; border: 1px solid #404957; border-radius: 4px; color: #76818d; font-size: 9px; }
.menu-category { padding: 9px 10px 4px; color: #697581; font-size: 9px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.node-menu-item { width: 100%; display: grid; grid-template-columns: 25px 1fr; gap: 9px; padding: 8px 10px; text-align: left; background: transparent; }
.node-menu-item:hover, .node-menu-item.focused { background: #262d37; }
.node-menu-item .mini-glyph { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--item-color); color: #121417; font-weight: 900; }
.node-menu-item small { display: block; color: #7d8894; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 47px; transform: translate(-50%, 12px); padding: 8px 12px; border: 1px solid #414a56; border-radius: 7px; background: #171c23ee; color: #dbe1e8; opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(260px, 52fr) minmax(260px, 48fr) 30px; }
  .parameters { display: none; position: fixed; z-index: 40; inset: 48px 0 30px auto; width: min(320px, 92vw); box-shadow: -12px 0 40px #000a; }
  .parameters.visible { display: block; }
  .viewport-shell { grid-column: 1; }
  .network-shell { grid-column: 1; }
  .menu, .gpu-status, .quality-label { display: none; }
  .transport { gap: 5px; }
}

@media (max-width: 520px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .brand .subtle, .version, #stopButton { display: none; }
  .network-actions button:not(.accent-button) { display: none; }
  .node { width: 176px; }
}
