/* PARTRUS — particle systems. Same family as NODRUS: Blender-style nodes, IBM Plex Mono, dark by default */
:root {
  --bg: #0a0a10; --panel: #15151d; --panel2: #1d1d27; --line: #2b2b38;
  --text: #d8dbe6; --dim: #8a8ea3; --accent: #66ff33; --m: #ff3fa4; --y: #ffd23f; --red: #ff2a4d;
  --t-float: #a1a1a1; --t-color: #c7c729; --t-part: #ff8a3d;
  --font: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --accent-rgb: 102,255,51; --m-rgb: 255,63,164; --bg-rgb: 10,10,16; --hi-rgb: 255,255,255;
  --head: #fff; --sel: #fff; --node: rgba(32, 32, 42, 0.96); --node-bd: #000;
  --ctl: #2b2b38; --ctl-bd: #111; --fill: #3d5a9c; --field: #11111a; --field-bd: #333; --hover-bd: #555;
  --grid: rgba(255,255,255,0.035); --wire: rgba(220,220,230,0.55); --shadow: 0 6px 18px rgba(0,0,0,0.45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font: 12px/1.4 var(--font); overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
body { display: grid; grid-template-rows: 44px minmax(0, 1fr) 24px; }

/* top bar */
.pa-bar { display: flex; align-items: center; gap: 6px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.pa-bar::-webkit-scrollbar { display: none; }
.pa-logo { font-weight: 700; font-size: 16px; letter-spacing: .08em; color: var(--head); text-decoration: none; margin-right: 6px; white-space: nowrap; }
.pa-logo span { color: var(--t-part); text-shadow: 0 0 12px rgba(255,138,61,0.55); }
.pa-name { width: 210px; min-width: 120px; height: 30px; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 0 8px; font-weight: 700; color: var(--head); }
.pa-name:hover, .pa-name:focus { border-color: var(--line); background: var(--panel2); outline: none; }
.pa-btn { height: 30px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel2); white-space: nowrap; flex: none; }
.pa-btn:hover { border-color: var(--accent); color: var(--accent); }
.pa-btn.is-on { border-color: var(--accent); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb),0.3); }
.pa-btn.is-dirty::after { content: ' •'; color: var(--y); }
.pa-tap b { color: var(--head); font-variant-numeric: tabular-nums; }
.pa-tap.beat { border-color: var(--accent); }
.pa-sp { flex: 1; min-width: 8px; }
@media (max-width: 1180px) { .pa-bar .nl { display: none; } }

/* main: the nodes fill it; the preview floats over them (or sits behind them: ▣) */
.pa-main { position: relative; min-height: 0; overflow: hidden; }
.pa-graph { position: absolute; inset: 0; z-index: 1; overflow: hidden; background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px; cursor: default; touch-action: none; }
.pa-graph.panning { cursor: grabbing; }
.pa-wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.pa-wires path { fill: none; stroke: var(--wire); stroke-width: 2; }
.pa-wires path.t-part { stroke: var(--t-part); stroke-width: 3; }
.pa-wires path.t-float { stroke: var(--t-float); }
.pa-wires path.drag { stroke-dasharray: 5 4; }
.pa-nodes { position: absolute; left: 0; top: 0; transform-origin: 0 0; z-index: 2; }
.pa-add { position: absolute; left: 12px; bottom: 12px; z-index: 5; height: 32px; padding: 0 14px; border-radius: 16px; border: 1px solid rgba(var(--accent-rgb),0.6); background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }
.pa-add:hover { background: var(--accent); color: var(--bg); }
.pa-err { position: absolute; left: 12px; right: 12px; top: 10px; z-index: 5; padding: 7px 10px; border-radius: 7px; background: rgba(255,42,77,0.16); border: 1px solid rgba(255,42,77,0.6); color: var(--head); }
.pa-hint { position: absolute; right: 12px; bottom: 14px; z-index: 4; color: var(--dim); font-size: 11px; pointer-events: none; text-align: right; }

/* nodes */
.nd { position: absolute; width: 216px; border-radius: 7px; background: var(--node); border: 1px solid var(--node-bd); box-shadow: var(--shadow); user-select: none; }
.nd.is-sel { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel), var(--shadow); }
.nd.is-off { opacity: 0.55; }
.nd-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 26px; padding: 0 8px; border-radius: 6px 6px 0 0; background: var(--cat, #444); color: #fff; font-weight: 600; cursor: grab; }
.nd-head:active { cursor: grabbing; }
.nd-x { background: none; border: 0; color: rgba(255,255,255,0.65); font-size: 15px; line-height: 1; padding: 2px 4px; }
.nd-x:hover { color: #fff; }
.nd-body { padding: 6px 0 8px; }
.nd-row { position: relative; display: flex; align-items: center; min-height: 24px; padding: 2px 12px; gap: 6px; }
.nd-row.out { justify-content: flex-end; }
.nd-row .lbl { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nd-row select { width: 100%; height: 22px; background: var(--ctl); border: 1px solid var(--ctl-bd); border-radius: 4px; padding: 0 4px; }
.nd-row .linked { flex: 1; color: var(--dim); font-style: italic; }
.sock { position: absolute; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; border: 1.5px solid var(--node-bd); cursor: crosshair; z-index: 3; }
.sock::after { content: ''; position: absolute; inset: -8px; }
.nd-row.in .sock { left: -6px; }
.nd-row.out .sock { right: -6px; }
.sock.t-float { background: var(--t-float); }
.sock.t-color { background: var(--t-color); }
.sock.t-part { background: var(--t-part); width: 14px; height: 14px; margin-top: -7px; border-radius: 3px; transform: rotate(45deg); }
.nd-row.in .sock.t-part { left: -7px; }
.nd-row.out .sock.t-part { right: -7px; }
.sock:hover, .sock.hot { box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.6); }
.nd-help { padding: 0 12px 4px; color: var(--dim); font-size: 11px; line-height: 1.3; }

/* Blender-like number: drag sideways, click to type */
.num { position: relative; flex: 1; height: 20px; border-radius: 4px; overflow: hidden; background: var(--ctl); border: 1px solid var(--ctl-bd); cursor: ew-resize; display: flex; align-items: center; justify-content: space-between; padding: 0 7px; }
.num-fill { position: absolute; inset: 0 auto 0 0; background: var(--fill); pointer-events: none; }
.num span { position: relative; z-index: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num .num-v { color: var(--head); margin-left: 6px; font-variant-numeric: tabular-nums; }
.num input { position: absolute; inset: 0; z-index: 2; width: 100%; border: 0; background: var(--field); color: var(--head); padding: 0 7px; text-align: center; }
.colorw { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.colorw input { width: 46px; height: 20px; border: 1px solid var(--ctl-bd); border-radius: 4px; background: none; padding: 0; cursor: pointer; }

/* preview: always a dark screen (it is the output), in both themes. A window over the nodes, like NODRUS */
.pa-view { position: absolute; z-index: 8; top: 12px; right: 12px; display: flex; flex-direction: column; min-width: 0; background: #000; color: #d8dbe6;
  border: 1px solid #2b2b38; border-radius: 8px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.pa-view.is-moving { opacity: 0.9; }
.pa-grip { position: absolute; left: 0; right: 0; top: 0; height: 20px; z-index: 3; cursor: move; display: flex; align-items: center; padding: 0 8px;
  background: linear-gradient(rgba(0,0,0,0.65), transparent); opacity: 0; transition: opacity .15s; }
.pa-view:hover .pa-grip { opacity: 1; }
.pa-grip span { font-size: 10px; letter-spacing: .12em; color: #8a8ea3; font-weight: 700; }
.pa-wsize { position: absolute; left: 0; bottom: 0; width: 16px; height: 16px; z-index: 4; cursor: nesw-resize;
  background: linear-gradient(45deg, transparent 45%, #66ff33 45% 55%, transparent 55% 70%, #66ff33 70% 80%, transparent 80%); opacity: 0; }
.pa-view:hover .pa-wsize { opacity: 0.7; }
.pa-stage { position: relative; flex: none; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #000; }
.pa-stage canvas { display: block; background: #000; }
.pa-stage .frame { position: relative; }
.pa-viewbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 6px; background: #101016; border-top: 1px solid #22222c; }
.pa-viewbar button, .pa-viewbar select { height: 24px; padding: 0 7px; border-radius: 5px; border: 1px solid #2b2b38; background: #1d1d27; color: #d8dbe6; }
.pa-viewbar button:hover { border-color: #66ff33; color: #66ff33; }
.pa-viewbar button.is-on { border-color: #66ff33; color: #66ff33; }
.pa-viewbar button.is-rec { border-color: #ff2a4d; color: #fff; background: #ff2a4d; animation: pa-rec 1s steps(2) infinite; }
@keyframes pa-rec { 50% { background: #8f1029; } }
.pa-sizes { display: inline-flex; gap: 2px; margin-right: 4px; }
.pa-viewbar .count { margin-left: auto; color: #8a8ea3; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pa-viewbar .count.rec { color: #ff6b81; }
/* narrow window: icons only */
.pa-view.is-narrow .pa-viewbar .nl, .pa-view.is-narrow .pa-viewbar .count { display: none; }
/* ▣ the preview behind the nodes: it fills the area, the grid goes, the bar floats at the top right */
.pa-main.backdrop .pa-view { inset: 0 !important; width: auto !important; height: auto !important; z-index: 0; border: 0; border-radius: 0; box-shadow: none; }
.pa-main.backdrop .pa-stage { position: absolute; inset: 0; width: auto !important; height: auto !important; }
.pa-main.backdrop .pa-grip, .pa-main.backdrop .pa-wsize { display: none; }
.pa-main.backdrop .pa-graph { background: transparent; }
.pa-main.backdrop .pa-graph.orbit { cursor: grabbing; }
.pa-main.backdrop > .pa-viewbar { position: absolute; z-index: 8; top: 10px; right: 10px; max-width: calc(100% - 20px); border: 1px solid #2b2b38; border-radius: 8px; background: rgba(16,16,22,0.88); }
.pa-main.backdrop .pa-hint { text-shadow: 0 1px 2px #000; }
.pa-view:fullscreen { border: 0; border-radius: 0; cursor: none; }
.pa-view:fullscreen .pa-stage { position: absolute; inset: 0; width: auto !important; height: auto !important; }
.pa-view:fullscreen .pa-viewbar, .pa-view:fullscreen .pa-grip, .pa-view:fullscreen .pa-wsize { display: none; }
/* the export popover */
.pa-exp { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; padding: 4px 8px 8px; }
.pa-exp > span { color: var(--dim); }
.pa-seg { display: flex; flex-wrap: wrap; gap: 3px; }
.pa-seg button { height: 24px; padding: 0 8px; border-radius: 5px; border: 1px solid var(--line); background: var(--panel2); }
.pa-seg button.is-on { border-color: var(--accent); color: var(--accent); }
.pa-pop .it.big { justify-content: flex-start; font-weight: 600; }
.pa-pop .it.rec { color: #ff6b81; }
.pa-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center; color: #ffb3c0; }

/* status bar */
.pa-eng { cursor: pointer; padding: 0 6px; border-radius: 4px; border: 1px solid transparent; }
.pa-eng:hover { border-color: var(--line); }
.pa-eng.ok { color: var(--accent); }
.pa-status { display: flex; align-items: center; gap: 14px; padding: 0 10px; background: var(--panel); border-top: 1px solid var(--line); color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; }
.pa-status b { color: var(--text); font-weight: 400; }
.pa-status .ok { color: var(--accent); }
.pa-status .bad { color: #ff7a7a; }
.pa-meter { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; vertical-align: middle; }
.pa-meter i { width: 4px; background: var(--accent); height: 1px; }

/* popovers and dialogs */
.pa-pop { position: fixed; z-index: 100; min-width: 220px; max-width: 360px; max-height: 70vh; overflow: auto; padding: 6px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.pa-pop h4 { margin: 6px 8px 4px; font-size: 11px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.pa-pop .it { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 6px 8px; border: 0; border-radius: 6px; background: none; }
.pa-pop .it:hover, .pa-pop .it.is-on { background: var(--panel2); color: var(--accent); }
.pa-pop .it i { font-style: normal; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pa-pop .it small { margin-left: auto; color: var(--dim); }
.pa-pop .it .del { margin-left: auto; padding: 0 6px; border: 0; background: none; color: var(--dim); }
.pa-pop .it .del:hover { color: var(--red); }
.pa-pop p { padding: 4px 8px 6px; color: var(--dim); max-width: 330px; }
.pa-pop .empty { padding: 6px 8px; color: var(--dim); }
.pa-modal { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.55); padding: 16px; }
.pa-modal[hidden] { display: none; }
.pa-card { width: min(640px, 100%); max-height: 86vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.pa-card h2 { font-size: 16px; color: var(--head); margin-bottom: 10px; }
.pa-card h3 { font-size: 12px; color: var(--accent); margin: 14px 0 4px; text-transform: uppercase; letter-spacing: .06em; }
.pa-card p, .pa-card li { color: var(--text); margin: 4px 0; }
.pa-card ul { padding-left: 18px; }
.pa-card kbd { padding: 0 5px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel2); font: inherit; font-size: 11px; }
.pa-card .row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pa-toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px); z-index: 130; padding: 8px 14px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); color: var(--head); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 80vw; }
.pa-toast.show { opacity: 1; transform: translateX(-50%); }
.pa-toast.bad { border-color: var(--red); }

/* ── LIGHT THEME (opt-in: /js/theme.js sets data-theme="light" on <html>) — the same panel as NODRUS in light ── */
:root[data-theme="light"] {
  --bg: #e8e6de; --panel: #f3f1ea; --panel2: #ebe2c8; --line: #c4bfb2;
  --text: #2b2f35; --dim: #5a6169; --accent: #b23c08; --m: #a8246a; --y: #865600; --red: #c21f3a;
  --t-float: #6f6f6f; --t-color: #8a8a10; --t-part: #c2560f;
  --accent-rgb: 178,60,8; --bg-rgb: 232,230,222; --hi-rgb: 43,47,53;
  --head: #1b1e22; --sel: #1b1e22; --node: rgba(250,249,245,0.97); --node-bd: #8f897b;
  --ctl: #e9e1c9; --ctl-bd: #b5b0a3; --fill: #a9c0ea; --field: #fbfaf6; --field-bd: #b5b0a3; --hover-bd: #8f897b;
  --grid: rgba(43,47,53,0.06); --wire: rgba(43,47,53,0.55); --shadow: 0 3px 10px rgba(43,47,53,0.22);
}
/* the top bar and the status bar are the dark slate strips */
:root[data-theme="light"] .pa-bar, :root[data-theme="light"] .pa-status {
  color: var(--text);
  --panel: #3c444d; --panel2: #2f363d; --line: rgba(255,255,255,0.18);
  --text: #eceef0; --dim: #c2c8cf; --accent: #ffa066; --accent-rgb: 255,160,102; --head: #fff; --y: #ffd27a; --t-part: #ffa066;
}
:root[data-theme="light"] .pa-status .bad { color: #ff8fa0; }
:root[data-theme="light"] .pa-err { background: rgba(194,31,58,0.1); }
:root[data-theme="light"] .pa-modal { background: rgba(43,47,53,0.45); }
:root[data-theme="light"] .pa-pop, :root[data-theme="light"] .pa-card { box-shadow: 0 10px 30px rgba(43,47,53,0.25); }

/* text and picture fields of the «Emisor de forma» */
.nd-text { width: 100%; resize: vertical; min-height: 34px; background: var(--field); color: var(--head); border: 1px solid var(--field-bd); border-radius: 4px; padding: 4px 6px; font: inherit; }
.nd-file { width: 100%; height: 24px; border-radius: 4px; border: 1px dashed var(--hover-bd); background: var(--field); text-align: left; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-file:hover { border-color: var(--accent); color: var(--accent); }

/* a knob shown on the NODRUS node · dragging the preview turns the 3D camera */
.num.is-pub { box-shadow: inset 3px 0 0 var(--m); }
.pa-stage { cursor: grab; }
.pa-stage.orbit { cursor: grabbing; }

/* the GLSL editor */
.pa-card.pa-code { width: min(860px, 100%); }
.pa-code textarea { width: 100%; height: 52vh; resize: vertical; background: var(--field); color: var(--head); border: 1px solid var(--field-bd); border-radius: 7px; padding: 10px 12px; font: 13px/1.5 var(--font); tab-size: 2; white-space: pre; }
.pa-codemsg { min-height: 1.4em; color: var(--dim); }
.pa-codemsg.bad { color: var(--red); }
.pa-codemsg.ok { color: var(--accent); }
.nd-file.nd-code { border-style: solid; border-color: rgba(var(--m-rgb),0.6); }
