/* vacnet Netzeditor -- Farben aus vacnet/theme.py (Palette des Dashboards) */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #dbe8f8;
  --danger: #d03b3b;
  --warn: #fab219;
  --good: #0ca30c;
  --node-fill: #ffffff;
  --node-stroke: #52514e;
  --fixed-fill: #ece9df;
  --chan: #52514e;
  --sel: #eb6834;
  --problem: #d03b3b;
  --stale: #898781;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --accent: #3987e5; --accent-soft: #1d3350;
    --node-fill: #232321; --node-stroke: #c3c2b7; --fixed-fill: #34322c;
    --chan: #c3c2b7; --sel: #d95926; --problem: #e66767;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 4px 16px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --accent: #3987e5; --accent-soft: #1d3350;
  --node-fill: #232321; --node-stroke: #c3c2b7; --fixed-fill: #34322c;
  --chan: #c3c2b7; --sel: #d95926; --problem: #e66767;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--page); color: var(--ink);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font: 11px ui-monospace, monospace; color: var(--muted); margin-left: auto; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Kopfleiste ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  background: var(--surface); border-bottom: 1px solid var(--grid);
  min-height: 46px; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .02em; color: var(--accent); margin-right: 6px; }
.menus { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.menu { position: relative; }
.menu-btn, .plain {
  background: none; border: 1px solid transparent; border-radius: 6px; padding: 5px 9px;
}
.menu-btn:hover, .plain:hover, .menu-btn[aria-expanded="true"] { background: var(--surface-2); }
.menu-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; min-width: 220px;
  background: var(--surface); border: 1px solid var(--grid); border-radius: 8px;
  box-shadow: var(--shadow); padding: 5px; display: flex; flex-direction: column;
}
.menu-pop.wide { min-width: 300px; }
.menu-pop button {
  display: flex; align-items: center; text-align: left; background: none; border: 0;
  padding: 6px 9px; border-radius: 5px; gap: 8px;
}
.menu-pop button:hover, .menu-pop button:focus-visible { background: var(--accent-soft); outline: none; }
.menu-sep { border-top: 1px solid var(--grid); margin: 5px 0; }
.menu-label { font-size: 11px; color: var(--muted); padding: 4px 9px; text-transform: uppercase; letter-spacing: .04em; }
.species-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; padding: 4px 9px; align-items: center; }
.species-grid .hdr { font-size: 11px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 7px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 5px 10px; }
.seg button + button { border-left: 1px solid var(--axis); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.topright { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status { color: var(--ink-2); font-size: 12px; max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.primary {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 7px;
  padding: 7px 14px; font-weight: 600;
}
.primary:disabled { opacity: .5; cursor: default; }
.danger { background: none; color: var(--danger); border: 1px solid var(--danger); border-radius: 7px; padding: 6px 12px; }
.badge {
  background: var(--danger); color: #fff; border: 0; border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.badge.warn { background: var(--warn); color: #000; }

/* ---------- Layout ---------- */
.layout { flex: 1; display: grid; grid-template-columns: 92px 1fr 360px; min-height: 0; }
.palette {
  background: var(--surface); border-right: 1px solid var(--grid);
  display: flex; flex-direction: column; gap: 4px; padding: 8px 6px; overflow-y: auto;
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 2px;
  font-size: 11.5px; color: var(--ink-2); user-select: none;
}
.tool svg { width: 40px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.tool:hover { background: var(--surface-2); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.tool.small { flex-direction: row; justify-content: center; font-size: 12px; padding: 5px 2px; }
.palette-sep { border-top: 1px solid var(--grid); margin: 6px 4px; }

.canvas-wrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#canvas { width: 100%; height: 100%; display: block; background: var(--page); outline: none; touch-action: none; }
#canvas.tool-channel, #canvas.tool-channel * { cursor: crosshair; }
#canvas.panning { cursor: grabbing; }
.grid-line { fill: none; stroke: var(--grid); stroke-width: .6; }
.canvas-hint {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  color: var(--muted); text-align: center; pointer-events: none; font-size: 14px; max-width: 420px;
}
.timebar {
  position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--grid); border-radius: 8px; padding: 6px 12px; box-shadow: var(--shadow);
}
.timebar input { flex: 1; }
#time-label { font-variant-numeric: tabular-nums; min-width: 120px; text-align: right; }

/* ---------- Zeichnung ---------- */
.node rect.body { fill: var(--node-fill); stroke: var(--node-stroke); stroke-width: 1.4; }
.node.fixed rect.body { fill: var(--fixed-fill); stroke-dasharray: 5 3; }
.node text { fill: var(--ink); font-size: 12px; text-anchor: middle; pointer-events: none; }
.node text.name { font-weight: 650; }
.node text.val { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.node { cursor: move; }
.sel rect.body, .sel circle.body { stroke: var(--sel) !important; stroke-width: 2.6 !important; }
.problem rect.body, .problem circle.body { stroke: var(--problem); stroke-width: 2.2; }
.chan path.line { fill: none; stroke: var(--chan); stroke-width: 2; }
.chan path.hit { fill: none; stroke: transparent; stroke-width: 16; cursor: pointer; }
.chan rect.glyph { fill: var(--surface); stroke: var(--chan); stroke-width: 1.3; }
.chan text { fill: var(--ink); font-size: 11px; text-anchor: middle; pointer-events: none; }
.chan text.val { fill: var(--ink-2); font-variant-numeric: tabular-nums; font-size: 10.5px; }
.chan text.name { font-weight: 600; }
.chan text.lab { text-anchor: start; }
.chan text { paint-order: stroke; stroke: var(--page); stroke-width: 3px; stroke-linejoin: round; }
.chan.sel path.line { stroke: var(--sel); stroke-width: 3; }
.chan.sel rect.glyph { stroke: var(--sel); stroke-width: 2; }
.chan.problem path.line { stroke: var(--problem); stroke-dasharray: 6 4; }
.arrow-head { fill: var(--chan); }
.link { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 3 3; fill: none; }
.link.loose { stroke: var(--problem); }
.elem { cursor: move; }
.elem circle.body { fill: var(--surface); stroke: var(--node-stroke); stroke-width: 1.4; }
.elem path.icon { fill: none; stroke: var(--ink-2); stroke-width: 1.6; pointer-events: none; }
.elem text { fill: var(--ink-2); font-size: 11px; text-anchor: middle; pointer-events: none; }
.elem.drop-target circle.body, .node.drop-target rect.body { stroke: var(--accent); stroke-width: 3; }
.rubber { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 4; fill: none; pointer-events: none; }
.stale text.val { fill: var(--stale); font-style: italic; }

/* ---------- Seitenleiste ---------- */
.side { background: var(--surface); border-left: 1px solid var(--grid); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--grid); }
.tabs button { flex: 1; background: none; border: 0; padding: 9px; color: var(--ink-2); border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab-body { overflow-y: auto; padding: 12px 14px 40px; flex: 1; }
.tab-body h3 { margin: 4px 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.tab-body h4 { margin: 14px 0 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kind { font-size: 11px; font-weight: 500; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 140px; gap: 8px; align-items: center; margin: 4px 0; }
.row label { color: var(--ink-2); display: flex; align-items: center; gap: 4px; min-width: 0; }
.row label .unit { color: var(--muted); font-size: 11px; }
.row .help { color: var(--muted); border: 1px solid var(--axis); border-radius: 50%; width: 15px; height: 15px; font-size: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: help; flex: none; }
.row input[type="text"], .row select, .row textarea {
  width: 100%; border: 1px solid var(--axis); border-radius: 5px; padding: 4px 6px; background: var(--page);
}
.row textarea { font: 12px ui-monospace, monospace; min-height: 64px; }
.row.wide { grid-template-columns: 1fr; }
.row input.invalid, .row select.invalid { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--page)); }
.row input.changed { border-color: var(--accent); }
.row .chk { justify-self: start; }
.err { color: var(--danger); font-size: 12px; margin: 2px 0 6px; }
.problems-box { border: 1px solid var(--danger); border-radius: 7px; padding: 6px 9px; margin: 0 0 10px; background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.problems-box li { margin: 2px 0; }
.problems-box button { background: none; border: 0; padding: 0; color: var(--ink); text-align: left; text-decoration: underline dotted; }
.hint-box { border: 1px solid var(--warn); border-radius: 7px; padding: 6px 9px; margin: 0 0 10px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.btn { background: var(--surface-2); border: 1px solid var(--axis); border-radius: 6px; padding: 5px 10px; }
.btn:hover { border-color: var(--ink-2); }
.btn.del { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--axis)); }
.sub { border-left: 2px solid var(--grid); padding-left: 10px; margin: 4px 0 8px; }
.note { color: var(--muted); font-size: 12px; margin: 6px 0; }
ul.plain { margin: 4px 0; padding-left: 18px; }

table.res { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; margin: 4px 0 10px; }
table.res th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--grid); padding: 3px 4px; }
table.res td { border-bottom: 1px solid var(--grid); padding: 3px 4px; }
table.res td.num { text-align: right; }
table.res tr.clickable { cursor: pointer; }
table.res tr.clickable:hover { background: var(--surface-2); }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.chart { width: 100%; height: 220px; display: block; }
.chart .axis { stroke: var(--axis); }
.chart .gridl { stroke: var(--grid); }
.chart text { fill: var(--muted); font-size: 10px; }
.chart path.series { fill: none; stroke-width: 1.8; }
.chart line.cursor { stroke: var(--ink-2); stroke-dasharray: 3 3; }
.regime-legend { margin: 2px 0 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-2); }

/* ---------- Dialog ---------- */
dialog {
  border: 1px solid var(--grid); border-radius: 10px; padding: 0; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 60px);
}
dialog::backdrop { background: rgba(0,0,0,.25); }
.dlg-form { display: flex; flex-direction: column; max-height: calc(100vh - 62px); }
.dlg-form h2 { margin: 0; padding: 14px 18px 8px; font-size: 16px; }
#dlg-body { overflow-y: auto; padding: 4px 18px 10px; }
#dlg-body .row { grid-template-columns: 1fr 170px auto; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 18px 14px; border-top: 1px solid var(--grid); }
.reset { background: none; border: 0; color: var(--accent); font-size: 12px; padding: 0 4px; }
textarea.code { width: 100%; height: 50vh; font: 12px/1.45 ui-monospace, Consolas, monospace; border: 1px solid var(--axis); border-radius: 6px; padding: 8px; background: var(--page); white-space: pre; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 74px 1fr; grid-template-rows: 1fr 45%; }
  .side { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--grid); }
}

/* Demo-Betrieb (Webseite, Nachtrag 68) */
.demo-banner { padding: 6px 14px; font-size: 13px; background: var(--accent-soft); color: var(--ink); border-bottom: 1px solid var(--line, var(--grid)); }
.demo-banner a { color: var(--accent); font-weight: 600; margin-left: 4px; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
