/* ============================================================
   SIGNALLABOR — Stil (Farbwelt und Schriften aus Patchbay)
   ============================================================ */
@font-face { font-display: swap; font-family: 'JetBrains Mono'; font-style: normal; font-weight: 300; src: url('font/jetbrains-mono-v24-latin/jetbrains-mono-v24-latin-300.woff2') format('woff2'); }
@font-face { font-display: swap; font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; src: url('font/jetbrains-mono-v24-latin/jetbrains-mono-v24-latin-regular.woff2') format('woff2'); }
@font-face { font-display: swap; font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; src: url('font/jetbrains-mono-v24-latin/jetbrains-mono-v24-latin-500.woff2') format('woff2'); }
@font-face { font-display: swap; font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 400; src: url('font/bricolage-grotesque-v9-latin/bricolage-grotesque-v9-latin-regular.woff2') format('woff2'); }
@font-face { font-display: swap; font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 700; src: url('font/bricolage-grotesque-v9-latin/bricolage-grotesque-v9-latin-700.woff2') format('woff2'); }

:root {
	--bg: #0c0d11;
	--panel: #14161c;
	--node: #1b1e26;
	--node2: #23262f;
	--line: rgba(255, 255, 255, 0.08);
	--line2: rgba(255, 255, 255, 0.14);
	--tx: #e7e9ee;
	--mut: #9aa1ae;
	--dim: #5b626f;
	--audio: #2dd4bf;
	--play: #34d399;
	--stop: #f87171;
	--mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
	--disp: 'Bricolage Grotesque', var(--mono);
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line2) transparent }
html, body { margin: 0; height: 100% }
body {
	background: var(--bg); color: var(--tx);
	font-family: var(--mono); font-size: 13px;
	display: flex; flex-direction: column; overflow: hidden;
	-webkit-font-smoothing: antialiased
}

/* ---------- Kopfleiste ---------- */
header {
	display: flex; align-items: center; gap: 12px;
	padding: 11px 18px;
	border-bottom: 1px solid var(--line);
	background: linear-gradient(180deg, #16181f, #101218);
	flex: 0 0 auto
}
.logo { font-family: var(--disp); font-weight: 700; font-size: 19px; letter-spacing: -0.5px; color: var(--tx); text-decoration: none }
.logo b { color: var(--audio) }
.sub { color: var(--mut); font-size: 11px; letter-spacing: .5px; text-transform: uppercase }
.spacer { flex: 1 }
.status { color: var(--dim); font-size: 11.5px; margin-right: 4px }
body.running .status { color: var(--play) }

.btn {
	font-family: var(--mono); font-size: 12px; color: var(--tx);
	background: var(--node); border: 1px solid var(--line2); border-radius: 7px;
	padding: 7px 12px; cursor: pointer; transition: .12s;
	display: inline-flex; align-items: center; gap: 6px; white-space: nowrap
}
.btn:hover { background: var(--node2); border-color: #3a3f4b }
.btn:active { transform: translateY(1px) }
.btn:disabled { opacity: .35; cursor: default; transform: none }
.btn.ghost { background: transparent }
.btn.play { background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .5); color: var(--play) }
.btn.play:hover:not(:disabled) { background: rgba(52, 211, 153, .2) }
.btn.stop { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .5); color: var(--stop) }
.btn.small { padding: 5px 10px; font-size: 11.5px }

main { flex: 1; display: flex; min-height: 0 }

/* ---------- Palette ---------- */
.palette {
	flex: 0 0 186px; background: var(--panel);
	border-right: 1px solid var(--line);
	padding: 14px 12px; overflow-y: auto
}
.palette h4 {
	margin: 14px 0 8px; font-size: 10px; letter-spacing: 1.2px;
	text-transform: uppercase; color: var(--dim)
}
.palette h4:first-child { margin-top: 0 }
.add {
	display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
	margin-bottom: 6px; background: var(--node); border: 1px solid var(--line);
	border-radius: 8px; padding: 8px 10px; color: var(--tx);
	font-family: var(--mono); font-size: 12px; cursor: grab; touch-action: none; transition: .12s
}
.add:hover { background: var(--node2); transform: translateX(2px) }
.swatch { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto }
.more-toggle {
	display: block; width: 100%; text-align: left; background: none; border: 0;
	color: var(--dim); font-family: var(--mono); font-size: 11px; padding: 2px 4px 6px; cursor: pointer
}
.more-toggle:hover { color: var(--tx) }
.more[hidden] { display: none }
.hint { color: var(--mut); font-size: 10.5px; line-height: 1.65; margin: 0 }
.hint b { color: var(--tx); font-weight: 500 }
.drag-ghost {
	position: fixed; z-index: 999; pointer-events: none;
	display: flex; align-items: center; gap: 9px;
	background: var(--node2); border: 1px solid var(--line2); border-radius: 8px;
	padding: 9px 12px; font-size: 12px; color: var(--tx);
	box-shadow: 0 10px 28px rgba(0, 0, 0, .55); opacity: .94;
	transform: translate(-50%, -50%)
}

/* ---------- Arbeitsfläche ---------- */
.stage {
	flex: 1; position: relative; overflow: hidden; cursor: grab; min-width: 0;
	background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .05) 1px, transparent 0);
	background-size: 22px 22px; background-color: var(--bg)
}
.stage.panning { cursor: grabbing }
.stage.dropok { box-shadow: inset 0 0 0 2px rgba(45, 212, 191, .45) }
.world { position: absolute; left: 0; top: 0 }
.content { position: absolute; left: 0; top: 0; zoom: 1 }
svg.wires { --wz: 1; position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; z-index: 1 }
svg.wires path { fill: none }
svg.wires path.wire { stroke-width: calc(2.4px * var(--wz)); opacity: .85 }
svg.wires path.wire.tmp { stroke-dasharray: calc(6px * var(--wz)) calc(5px * var(--wz)); opacity: .9 }
svg.wires path.wire.rest { opacity: .45 }
svg.wires path.hit { stroke: transparent; stroke-width: calc(14px * var(--wz)); pointer-events: stroke; cursor: pointer }
svg.wires path.hit:hover { stroke: rgba(248, 113, 113, .3) }
body.running svg.wires path.wire:not(.tmp) { stroke-dasharray: calc(10px * var(--wz)) calc(6px * var(--wz)); animation: flow .9s linear infinite }
@keyframes flow { to { stroke-dashoffset: calc(-16px * var(--wz)) } }

.empty {
	position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
	text-align: center; color: var(--dim); font-size: 13px; line-height: 1.8; pointer-events: none
}
/* Marker für Module außerhalb der Ansicht (Bildschirmkoordinaten) */
.indicators { position: absolute; inset: 0; pointer-events: none; z-index: 5 }
.indicator { position: absolute; pointer-events: auto; cursor: pointer; --c: #f87171 }
.idot {
	position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
	width: 13px; height: 13px; border-radius: 50%; background: var(--c); border: 2px solid var(--bg);
	box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 50%, transparent), 0 0 10px color-mix(in srgb, var(--c) 55%, transparent)
}
.iline {
	position: absolute; left: 0; top: 0; width: 26px; height: 2px; border-radius: 2px; opacity: .55;
	background: linear-gradient(90deg, var(--c), transparent); transform-origin: 0 50%
}
.ilbl {
	position: absolute; top: 0; font-size: 9px; color: var(--c); background: var(--node);
	padding: 1px 5px; border-radius: 4px; white-space: nowrap
}
.indicator:hover .ilbl { color: var(--tx) }

/* Aufklappmenü Beispiele */
.dd { position: relative }
.ddmenu {
	position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; width: 330px;
	background: var(--node); border: 1px solid var(--line2); border-radius: 9px; padding: 5px;
	box-shadow: 0 14px 34px rgba(0, 0, 0, .55)
}
.ddmenu[hidden] { display: none }
.ddmenu button {
	display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px;
	padding: 7px 9px; color: var(--tx); font-family: var(--mono); cursor: pointer
}
.ddmenu button:hover { background: var(--node2) }
.ddmenu b { display: block; font-weight: 500; font-size: 12px }
.ddmenu span { display: block; font-size: 10.5px; color: var(--mut); margin-top: 2px; line-height: 1.4 }

.zoomind {
	position: absolute; left: 12px; bottom: 12px; z-index: 5;
	background: var(--node); border: 1px solid var(--line2); border-radius: 7px;
	font-size: 11px; color: var(--mut); padding: 4px 9px; cursor: pointer
}

/* ---------- Module ---------- */
.node {
	position: absolute; background: var(--node);
	border: 1px solid var(--line2); border-radius: 11px; z-index: 2;
	box-shadow: 0 8px 24px rgba(0, 0, 0, .4); user-select: none; cursor: default
}
.node.sel { border-color: #4b5161; box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 55%, transparent), 0 8px 28px rgba(0, 0, 0, .5) }
.node.dragging { z-index: 4; opacity: .95 }
.nhead {
	display: flex; align-items: center; gap: 8px; padding: 9px 11px; height: 38px;
	cursor: grab; border-bottom: 1px solid var(--line); border-radius: 11px 11px 0 0;
	background: linear-gradient(90deg, color-mix(in srgb, var(--c) 14%, transparent), transparent 70%)
}
.nhead:active { cursor: grabbing }
.ntitle.custom { color: color-mix(in srgb, var(--c) 35%, #fff) }
.nrename {
	width: 100%; background: var(--bg); color: var(--tx); border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
	border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 12px; outline: none
}
.ndot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: 0 0 auto }
.ntitle { font-weight: 500; font-size: 12.5px; letter-spacing: .3px; flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.ncat { font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--dim) }
/* Kopf-Knöpfe: Hilfe, Ein-/Ausklappen, Entfernen */
.nbtns { display: inline-flex; gap: 3px; flex: 0 0 auto; margin-left: auto }
.nhelp, .ntoggle, .nclose, .nexp, .npop, .ncompact {
	width: 19px; height: 19px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
	background: transparent; border: 1px solid var(--line2); border-radius: 5px;
	color: var(--dim); font-family: var(--mono); font-size: 11px; font-weight: 700; line-height: 1;
	cursor: pointer; transition: .12s
}
.nclose { font-size: 14px; font-weight: 400 }
.ntoggle { font-size: 9px }
.nhelp:hover, .ntoggle:hover, .nexp:hover, .npop:hover, .ncompact:hover, .ncompact.on { color: var(--tx); border-color: color-mix(in srgb, var(--c) 60%, transparent); background: color-mix(in srgb, var(--c) 14%, transparent) }
.nclose:hover { color: var(--stop); border-color: rgba(248, 113, 113, .5); background: rgba(248, 113, 113, .14) }

/* Eingeklappt: nur der Kopf, Kabel laufen in je einem Sammelpunkt zusammen */
.nmerge {
	display: none; position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%;
	transform: translateY(-50%); border: 2px solid var(--bg); pointer-events: none;
	background: linear-gradient(135deg, color-mix(in srgb, var(--c) 80%, #fff), var(--c));
	box-shadow: 0 0 0 1px var(--line2)
}
.nmerge.in { left: -8px }
.nmerge.out { right: -8px }
.nhead { position: relative }
.node.collapsed .nmerge { display: block }
.node.collapsed .nhead { border-bottom: none; border-radius: 11px }
.node.collapsed .nbody, .node.collapsed .nports, .node.collapsed .port { display: none }
.nbody { padding: 10px 10px 11px }
/* beschriftete Portreihen (Module mit mehreren Ein-/Ausgängen) */
.nports { border-bottom: 1px solid var(--line); padding-bottom: 3px }
.nprow { height: 22px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; font-size: 10.5px; color: var(--mut) }
.nprow span.rest { color: var(--dim); font-style: italic }
.nextra { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px }
.nextra:last-child { margin-bottom: 0; margin-top: 8px }
.nparams { display: flex; flex-direction: column; gap: 9px }
.node.wide .nparams { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px }
.node.wide .nparams .prow.range { grid-column: 1 / -1 }

/* Ports */
.port {
	position: absolute; width: 16px; height: 16px; border-radius: 50%;
	background: var(--bg); border: 2px solid var(--c); cursor: crosshair; z-index: 3; transition: box-shadow .12s, transform .12s
}
.port.in { left: -9px }
.port.out { right: -9px; background: var(--c) }
.port.out.rest { background: color-mix(in srgb, var(--c) 35%, var(--bg)) }
.port:hover, .port.hl { box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 30%, transparent) }
.port.hl { transform: scale(1.15) }

/* Parameter */
.prow label, .plbl { display: block; font-size: 10.5px; color: var(--mut); margin-bottom: 4px }
.plbl { display: flex; justify-content: space-between; align-items: baseline; gap: 6px }
.pval { color: var(--tx); font-size: 11px; white-space: nowrap }
.pval input {
	width: 64px; background: transparent; border: 1px solid transparent; border-radius: 4px;
	color: var(--tx); font-family: var(--mono); font-size: 11px; text-align: right; padding: 1px 3px
}
.pval input:hover, .pval input:focus { border-color: var(--line2); background: var(--bg); outline: none }
.pval input::-webkit-inner-spin-button { display: none }
.pval input { -moz-appearance: textfield; appearance: textfield }
select {
	width: 100%; background: var(--bg); color: var(--tx); border: 1px solid var(--line2);
	border-radius: 6px; padding: 5px 6px; font-family: var(--mono); font-size: 11.5px; outline: none
}
select:focus { border-color: color-mix(in srgb, var(--c) 60%, transparent) }
.prow label.chk { display: flex; align-items: center; gap: 6px; color: var(--tx); font-size: 11.5px; cursor: pointer; margin: 0 }
.chk input { accent-color: var(--c); margin: 0 }
input[type=range] { width: 100%; margin: 0; accent-color: var(--c); height: 16px; cursor: pointer }

/* Zusatz-Oberflächen */
canvas.plot { display: block; width: 100%; border-radius: 6px; border: 1px solid var(--line); background: #0a0b0f; cursor: crosshair }
.ninfo { font-size: 10.5px; color: var(--mut); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.ninfo.dim { color: var(--dim); white-space: normal }
.ninfo.wrap { white-space: normal }
.frow { display: flex; gap: 6px }
.frow .btn:first-child { flex: 1; justify-content: center }
.prog { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden }
.prog div { height: 100%; width: 0; background: var(--c); transition: width .08s linear }
.meter { position: relative; height: 10px; background: var(--bg); border-radius: 3px; overflow: hidden; border: 1px solid var(--line) }
.mbar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #34d399, #34d399 70%, #fbbf24 88%, #f87171) ; background-size: 194px 100% }
.mpeak { position: absolute; top: 0; bottom: 0; width: 2px; background: #e7e9ee; left: 0 }
.meter.clip { border-color: var(--stop) }
.recbtn { justify-content: center }
.recbtn.recording { background: rgba(248, 113, 113, .18); border-color: rgba(248, 113, 113, .6); color: var(--stop); animation: blink 1.2s ease-in-out infinite }
@keyframes blink { 50% { opacity: .65 } }

/* Toast */
/* Nur Bild / Auswahlrahmen */
.node.compact .nparams { display: none }
.node.compact .nextra { margin-bottom: 0 }
.marquee { position: absolute; z-index: 6; border: 1px dashed var(--audio); background: rgba(45, 212, 191, .08); pointer-events: none }

/* Größe ändern (Anzeige-Module) */
.nresize {
	position: absolute; right: 2px; bottom: 2px; width: 14px; height: 14px; cursor: nwse-resize; z-index: 3;
	background: linear-gradient(135deg, transparent 50%, color-mix(in srgb, var(--c) 55%, transparent) 50%, color-mix(in srgb, var(--c) 55%, transparent) 60%, transparent 60%, transparent 70%, color-mix(in srgb, var(--c) 55%, transparent) 70%, color-mix(in srgb, var(--c) 55%, transparent) 80%, transparent 80%);
	border-radius: 0 0 9px 0; opacity: .7
}
.nresize:hover { opacity: 1 }
.node.collapsed .nresize { display: none }

/* Messgerät */
.mgrid { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; align-items: baseline }
.mgrid .ml { font-size: 10.5px; color: var(--mut); white-space: nowrap }
.mgrid .mv { font-size: 12.5px; color: var(--tx); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums }
.meter.red .mbar { background: linear-gradient(90deg, #fbbf24, #f87171); background-size: auto }

/* Bild-Export */
.exrow { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; font-size: 12px; color: var(--mut) }
.exwh { display: flex; align-items: center; gap: 6px; color: var(--mut) }
.exwh input {
	width: 80px; background: var(--bg); color: var(--tx); border: 1px solid var(--line2); border-radius: 6px;
	padding: 5px 7px; font-family: var(--mono); font-size: 12px
}
.sheet .acts { display: flex; justify-content: flex-end; gap: 8px }
.sheet label.chk { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--tx) }

/* Rechtsklickmenü */
.ctx {
	position: fixed; z-index: 950; min-width: 210px; padding: 5px;
	background: var(--node); border: 1px solid var(--line2); border-radius: 9px;
	box-shadow: 0 14px 34px rgba(0, 0, 0, .6); font-family: var(--mono)
}
.ctx[hidden] { display: none }
.ctx-item {
	position: relative; display: flex; align-items: center; justify-content: space-between; gap: 18px;
	width: 100%; background: none; border: 0; border-radius: 6px; padding: 6px 9px;
	color: var(--tx); font-family: var(--mono); font-size: 12px; text-align: left; cursor: pointer
}
.ctx-item:hover:not(:disabled) { background: var(--node2) }
.ctx-item:disabled { color: var(--dim); cursor: default }
.ctx-item.danger { color: var(--stop) }
.ctx-l { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap }
.ctx-l .swatch { display: inline-block }
.ctx-k { color: var(--dim); font-size: 10.5px; white-space: nowrap }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 6px }
.ctx-sub { display: none; position: absolute; left: 100%; top: -6px }
.ctx.flip .ctx-sub { left: auto; right: 100% }
.ctx-item.has-sub:hover > .ctx-sub, .ctx-item.has-sub:focus-within > .ctx-sub { display: block }
.plbl2 { display: block; font-size: 10.5px; color: var(--mut); margin-bottom: -2px }
.frow select { flex: 1; min-width: 0 }

/* Hilfe-Fenster */
.help-btn {
	width: 26px; height: 26px; padding: 0; justify-content: center; border-radius: 50%;
	font-weight: 700; font-size: 13px; line-height: 1; flex: 0 0 auto
}
.modal {
	position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: none;
	align-items: center; justify-content: center; z-index: 900
}
.modal.show { display: flex }
.sheet {
	background: var(--panel); border: 1px solid var(--line2); border-radius: 12px;
	width: min(560px, 90vw); padding: 18px; display: flex; flex-direction: column; gap: 12px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, .6)
}
.sheet h3 { margin: 0; font-family: var(--disp); font-size: 16px }
.help-sheet { width: min(660px, 92vw); max-height: 86vh }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 12px }
.help-body { overflow-y: auto; padding-right: 6px; font-size: 13px; line-height: 1.62; color: var(--tx) }
.help-body p { margin: 0 0 10px }
.help-body h4 { margin: 16px 0 6px; font-family: var(--disp); font-size: 13px; color: var(--mut); letter-spacing: .3px; text-transform: none }
.help-body ul { margin: 0 0 10px; padding-left: 18px }
.help-body li { margin: 3px 0 }
.help-body b { color: #fff; font-weight: 600 }
.help-body code {
	font-family: var(--mono); font-size: 11.5px; background: var(--bg);
	border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px
}
.help-body .htip {
	margin-top: 10px; padding: 8px 11px; background: rgba(45, 212, 191, .08);
	border-left: 2px solid var(--audio); border-radius: 0 6px 6px 0; color: var(--mut); font-size: 12.5px
}
.help-body .hkbd { border-collapse: collapse; width: 100%; font-size: 12.5px }
.help-body .hkbd td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top }
.help-body .hkbd td:first-child { white-space: nowrap; width: 1% }

.toast {
	position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
	background: var(--node2); border: 1px solid var(--line2); border-radius: 8px;
	padding: 9px 16px; font-size: 12px; opacity: 0; pointer-events: none;
	transition: .2s; z-index: 1000; box-shadow: 0 10px 30px rgba(0, 0, 0, .5)
}
.toast.show { opacity: 1; transform: translate(-50%, 0) }

/* ---------- kleinere Fenster (bis Full HD und darunter) ---------- */
@media (max-height: 1000px) { .hint-h, .hint { display: none } .palette h4 { margin-top: 11px } .add { padding: 7px 10px; margin-bottom: 5px } }
@media (max-width: 1500px) { .sub { display: none } }
@media (max-width: 1150px) { header { gap: 7px; padding: 9px 10px } .btn { padding: 6px 8px } .status { display: none } }
