/* ---------- Токены. Светлая тема по умолчанию, тёмная — [data-theme="dark"] (ставит theme.js).
   Без JS тёмная берётся из системы через prefers-color-scheme. ---------- */
:root {
  --bg: #f4f6fb; --panel: #ffffff; --raised: #eef1f7; --hover: #e8ecf4;
  --ink: #0a0b0e; --ink-2: #2a2e37; --muted: #5d6371; --dim: #8b919e;
  --line: #0a0b0e1a; --line-soft: #0a0b0e12; --line-strong: #0a0b0e2e;
  --accent: #0a7fd8; --accent-strong: #0b95f5; --accent-ink: #ffffff;
  --accent-soft: #0b95f514; --accent-line: #0b95f566; --glow: #2f8bff4a;
  --green: #4f8f17; --green-ink: #0e1606; --light-btn: #0a0b0e; --light-btn-ink: #ffffff;
  --ok: #1d8a4a; --warn: #b26a00; --bad: #d92d36;
  --chip: #eef0f3; --nav-bg: #ffffffcc; --dot: #0a0b0e1c;
  --node: #ffffff; --input-node: #eef6ff;
  --shadow: 0 1px 2px #0a0b0e0a, 0 10px 30px #1b3fd014;
  --radius: 12px; --radius-lg: 16px; --radius-btn: 9px;
  --ease-enter: cubic-bezier(.16, 1, .3, 1);
  --font: "Inter", "Inter Variable", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand: "Caveat", "Segoe Script", cursive;
  font-family: var(--font); color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #050507; --panel: #0e1014; --raised: #12141b; --hover: #16181e;
  --ink: #f7f8fb; --ink-2: #d6dae2; --muted: #a3aab8; --dim: #6b7282;
  --line: #ffffff1a; --line-soft: #ffffff14; --line-strong: #ffffff2e;
  --accent: #4da8ff; --accent-strong: #0a8fff; --accent-ink: #ffffff;
  --accent-soft: #4da8ff1a; --accent-line: #0a8fff73; --glow: #307fff2b;
  --green: #63aa25; --green-ink: #111807; --light-btn: #f4f5f7; --light-btn-ink: #08090c;
  --ok: #3fbf72; --warn: #e3a336; --bad: #ff6568;
  --chip: #1d2027; --nav-bg: #111113cc; --dot: #ffffff21;
  --node: #15171d; --input-node: #142744;
  --shadow: 0 1px 2px #0006, 0 18px 35px #0008;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #050507; --panel: #0e1014; --raised: #12141b; --hover: #16181e;
    --ink: #f7f8fb; --ink-2: #d6dae2; --muted: #a3aab8; --dim: #6b7282;
    --line: #ffffff1a; --line-soft: #ffffff14; --line-strong: #ffffff2e;
    --accent: #4da8ff; --accent-strong: #0a8fff; --accent-ink: #ffffff;
    --accent-soft: #4da8ff1a; --accent-line: #0a8fff73; --glow: #307fff2b;
    --green: #63aa25; --green-ink: #111807; --light-btn: #f4f5f7; --light-btn-ink: #08090c;
    --ok: #3fbf72; --warn: #e3a336; --bad: #ff6568;
    --chip: #1d2027; --nav-bg: #111113cc; --dot: #ffffff21;
    --node: #15171d; --input-node: #142744;
    --shadow: 0 1px 2px #0006, 0 18px 35px #0008;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  transition: background-color .2s, color .2s; }
::selection { background: #5d9dff61; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3, h4 { font-weight: 500; letter-spacing: -.02em; }
button, .btn { font: inherit; font-size: 14px; font-weight: 500; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: var(--radius-btn); padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; line-height: 1.4;
  transition: transform .18s var(--ease-enter), background-color .18s, border-color .18s, color .18s; }
button:hover, .btn:hover { border-color: var(--line-strong); background: var(--hover); }
button.primary, .btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--accent-strong); filter: brightness(1.08); }
.btn.light { background: var(--light-btn); border-color: var(--light-btn); color: var(--light-btn-ink); font-weight: 600; }
.btn.light:hover { background: var(--light-btn); filter: brightness(1.1); }
.btn.green { background: var(--green); border-color: var(--green); color: var(--green-ink); font-weight: 600; }
.btn.ghost { background: transparent; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, textarea, select { font: inherit; width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel); color: var(--ink); transition: border-color .16s, box-shadow .16s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--dim); }

/* переключатель темы */
.theme-toggle { width: 38px; height: 38px; padding: 0; border-radius: 11px; flex: none; color: var(--ink-2); background: transparent; }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* общая обёртка и логотип */
.wrap { width: min(1320px, 100% - 80px); max-width: none; margin: 0 auto; padding: 0; }
@media (max-width: 700px) { .wrap { width: calc(100% - 32px); } }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 19px; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.logo span { color: var(--accent); }
.logo .mark { width: 28px; height: 28px; flex: none; border-radius: 9px; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 20% 10%, #8fd0ff 0%, #2f8bff 45%, #1b3fd0 100%);
  box-shadow: inset 0 0 0 1px #ffffff33, 0 6px 18px #2f8bff40; }
.logo .mark svg { width: 16px; height: 16px; color: #fff; }

/* вход */
.auth { max-width: 420px; margin: 8vh auto; padding: 0 16px; }

/* приложение */
.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.side { border-right: 1px solid var(--line); background: var(--panel); padding: 14px; display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.side .nav { text-align: left; border: none; background: none; padding: 8px 10px; border-radius: 8px; width: 100%; }
.side .nav.active, .side .nav:hover { background: var(--hover); }
.side .nav.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .credits { margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; background: var(--raised); }
.main { overflow: auto; position: relative; }
.page { padding: 24px; max-width: 980px; }
.page h2 { margin-top: 0; }
.boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.boards .card { cursor: pointer; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.banner { background: #fff3cd; color: #6b4e00; padding: 8px 14px; font-size: 14px; }
:root[data-theme="dark"] .banner { background: #2a2210; color: #f1d58a; }

/* доска: полноэкранный холст, плавающие панели, карточки */
body.board-open { overflow: hidden; display: flex; flex-direction: column; height: 100vh; }
body.board-open #banner { flex: none; }
body.board-open .app { flex: 1; min-height: 0; height: auto; grid-template-columns: 1fr; }
body.board-open .side { display: none; }
body.board-open .main { overflow: hidden; }
.main > .board { height: 100%; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .side { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .side .credits { margin: 0; }
}

.board {
  --b-bg: #f4f5f7; --b-panel: #ffffff; --b-card: #ffffff; --b-line: #dde0e6; --b-ink: #0a0b0e; --b-muted: #5d6371;
  --b-accent: #0b95f5; --b-dot: #c4c9d2; --b-wire: #0b95f5; --b-mini-node: #8fb8e8; --b-hover: #eef0f3;
  --b-shadow: 0 1px 2px #0a0b0e0f, 0 8px 24px #0a0b0e14;
  position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--b-bg); color: var(--b-ink);
  font-size: 14px;
}
:root[data-theme="dark"] .board {
  --b-bg: #08090c; --b-panel: #101218; --b-card: #15171d; --b-line: #2b313c; --b-ink: #eef0f4; --b-muted: #a3aab8;
  --b-accent: #4da8ff; --b-dot: #ffffff1c; --b-wire: #4da8ff; --b-mini-node: #93b7df; --b-hover: #1c2230;
  --b-shadow: 0 1px 2px #0008, 0 18px 35px #0009;
}
.board:focus-visible, .board button:focus-visible, .board input:focus-visible, .board textarea:focus-visible {
  outline: 2px solid var(--b-accent); outline-offset: 2px;
}

/* холст */
.scroller { position: absolute; inset: 0; overflow: auto; background: var(--b-bg); }
.scroller { scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.canvas { position: relative; width: 2400px; height: 1400px; background-color: var(--b-bg);
  background-image: radial-gradient(var(--b-dot) 1.2px, transparent 1.4px); background-size: 24px 24px; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#world > svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
#wires path.hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
#wires path.wire { fill: none; stroke: var(--b-wire); stroke-width: 2; stroke-linecap: round; }
#wires path.hit:hover + path.wire { stroke-width: 3; }
#wires path.wire.sel { stroke: var(--b-accent); stroke-width: 3.5; }
#wiresTmp path.tmp { fill: none; stroke: var(--b-accent); stroke-width: 2; stroke-dasharray: 6 5; }
#wiresTmp line.cutline { stroke: #e5484d; stroke-width: 2; stroke-dasharray: 5 4; }
.rband { position: absolute; border: 1px solid var(--b-accent); background: color-mix(in srgb, var(--b-accent) 10%, transparent); pointer-events: none; z-index: 5; }
.board[data-mode="hand"] .scroller, .board.spacepan .scroller { cursor: grab; }
.board.grabbing .scroller { cursor: grabbing; }
.board[data-mode="cut"] .scroller { cursor: crosshair; }
.board[data-mode="hand"] #world .node, .board[data-mode="hand"] #world .node *,
.board[data-mode="cut"] #world .node, .board[data-mode="cut"] #world .node *,
.board.spacepan #world .node, .board.spacepan #world .node * { pointer-events: none !important; }

/* карточки узлов: заголовок над карточкой, тёмная панель, ввод внизу */
.node { position: absolute; background: var(--b-card); border: 1px solid var(--b-line); border-radius: 14px;
  box-shadow: var(--b-shadow); user-select: none; }
.node.sel { box-shadow: 0 0 0 2px var(--b-accent), var(--b-shadow); }
.node.drop { box-shadow: 0 0 0 3px var(--b-accent); }
.node.card { overflow: visible; display: flex; flex-direction: column; }
.node.card > .head { position: absolute; left: 0; right: 0; top: -28px; height: 24px; display: flex; align-items: center;
  gap: 6px; padding: 0 4px; cursor: grab; font-weight: 600; font-size: 13px; color: var(--b-ink); }
.node.card > .head:hover .more { opacity: 1; }
.node.card .ico { width: 20px; height: 20px; border-radius: 6px; background: var(--b-hover); display: grid; place-items: center; font-size: 11px; flex: none; }
.node.card .ttl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node.card .more { opacity: .45; border: none; background: none; padding: 0 4px; height: 22px; color: var(--b-muted); font-size: 15px; line-height: 1; border-radius: 6px; }
.node.card .more:hover { background: var(--b-hover); color: var(--b-ink); }
.status { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--b-line); flex: none; }
.status.running { background: var(--warn); animation: pulse 1s infinite; } .status.done { background: var(--ok); } .status.error { background: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }
.node.card.busy { border-color: var(--warn); }
.node .port { position: absolute; top: 50%; width: 11px; height: 11px; margin-top: -6px; border-radius: 50%; background: var(--b-panel);
  border: 1.5px solid var(--b-muted); cursor: crosshair; z-index: 2; }
.node .port:hover { border-color: var(--b-accent); background: var(--b-accent); }
.node .port.in { left: -6px; } .node .port.out { right: -6px; }
.node .port.armed { background: var(--b-accent); border-color: var(--b-accent); }
.node.card .cbody { display: flex; flex-direction: column; gap: 0; }
.node.card .res { font-size: 13px; line-height: 1.45; color: var(--b-ink); white-space: pre-wrap; max-height: 114px; overflow: hidden;
  padding: 12px 14px 8px; cursor: pointer; }
.node.card .res.open { max-height: 320px; overflow: auto; }
.node.card .res.small { font-size: 12px; }
.node.card .composer { margin: 0 8px 8px; background: var(--b-bg); border: 1px solid var(--b-line); border-radius: 12px; padding: 8px 8px 6px; }
.node.card .composer:focus-within { border-color: var(--b-accent); }
.node.card .cin { min-height: 24px; border: none; padding: 2px 4px; resize: none; font-size: 13px; background: transparent; color: var(--b-ink); width: 100%; }
.node.card .composer:focus-within .cin { min-height: 64px; }
.node.card .cin:focus { outline: none; }
.node.card .crow { display: flex; gap: 4px; align-items: center; margin-top: 4px; }
.node.card .cbtn { width: 28px; height: 28px; padding: 0; border-radius: 8px; font-size: 13px; line-height: 1; border: none; background: none; color: var(--b-muted); }
.node.card .cbtn:hover:not(:disabled) { background: var(--b-hover); color: var(--b-ink); }
.node.card .cbtn:disabled { opacity: .45; cursor: default; }
.node.card .csend { background: var(--b-ink); color: var(--b-bg); border-radius: 50%; width: 30px; height: 30px; font-weight: 700; }
.node.card .csend:hover:not(:disabled) { background: var(--b-accent); color: #fff; }
.node.card .cmic.on, .node.card .cstop { background: #e5484d; color: #fff; }
.node.card.k-sticky { border: none; border-radius: 14px; overflow: visible; }
.node.card.note-1 { background: #fff4b8; } .node.card.note-2 { background: #d8f0ff; } .node.card.note-3 { background: #ffd9e4; }
:root[data-theme="dark"] .node.card.note-1 { background: #4a4220; } :root[data-theme="dark"] .node.card.note-2 { background: #142744; } :root[data-theme="dark"] .node.card.note-3 { background: #4a2633; }
.node.card .note-text { flex: 1; min-height: 0; border: none; background: transparent; font-size: 14px; resize: none; padding: 14px; color: var(--b-ink); }
.node.card .note-text:focus { outline: none; }
.node.card .note-colors { display: flex; gap: 6px; padding: 0 12px 10px; }
.node.card .dot { width: 14px; height: 14px; padding: 0; border-radius: 50%; border: 2px solid transparent; }
.node.card .dot.on { border-color: var(--b-ink); }
.node.card .dot.c1 { background: #ffe066; } .node.card .dot.c2 { background: #74c0fc; } .node.card .dot.c3 { background: #f783ac; }
.node.card .copen { margin: 8px 12px 12px; }
.node.card [hidden] { display: none; }
.node.card.k-llmImage .res, .node.card.k-llmVideo .res { max-height: none; }

/* рамки */
.node.frame { background: color-mix(in srgb, var(--b-accent) 6%, transparent); border: 1.5px dashed color-mix(in srgb, var(--b-accent) 50%, transparent);
  border-radius: 16px; box-shadow: none; pointer-events: none; }
.node.frame.collapsed { background: var(--b-panel); border-style: solid; }
.node.frame .fhead { pointer-events: auto; cursor: grab; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 12px;
  font-size: 13px; }
.node.frame .ftitle { font-weight: 600; color: var(--b-accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.node.frame .type { font-size: 12px; color: var(--b-muted); }
.node.frame .fbtn { border: none; background: none; height: 26px; padding: 0 6px; color: var(--b-muted); font-size: 15px; border-radius: 6px; }
.node.frame .fbtn:hover { background: var(--b-hover); color: var(--b-ink); }
.node.frame .rz { position: absolute; right: 3px; bottom: 3px; width: 16px; height: 16px; cursor: nwse-resize; pointer-events: auto;
  border-right: 2px solid var(--b-accent); border-bottom: 2px solid var(--b-accent); border-radius: 0 0 4px 0; opacity: .6; }
.node.frame.collapsed .rz { display: none; }
.board.ro .port, .board.ro .rz { display: none; }
.board.ro .node.card > .head { cursor: default; }

/* плавающие панели */
.pill { display: flex; align-items: center; gap: 2px; background: var(--b-panel); border: 1px solid var(--b-line); border-radius: 12px;
  box-shadow: var(--b-shadow); padding: 4px; pointer-events: auto; }
.topbar { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; pointer-events: none; z-index: 12; }
.topbar .tl { min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 6px; pointer-events: auto; flex-wrap: nowrap; min-width: 0; }
.toolbar > * { flex: none; }
.toolbar .pr-bar { display: flex; align-items: center; }
.board button { font: inherit; font-size: 13px; border: 1px solid var(--b-line); background: var(--b-panel); color: var(--b-ink);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; height: 32px; white-space: nowrap; }
.board button:hover:not(:disabled) { background: var(--b-hover); }
.board button:disabled { opacity: .45; cursor: default; }
.board button.primary { background: var(--b-accent); border-color: var(--b-accent); color: #fff; }
.board button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--b-accent); }
.board button.danger { color: #e5484d; }
.board .ib { border: none; background: transparent; min-width: 32px; width: auto; padding: 0 8px; height: 32px; font-size: 15px; line-height: 1; border-radius: 8px; }
.board .ib:hover:not(:disabled) { background: var(--b-hover); }
.board .ib.primary { background: var(--b-accent); color: #fff; }
.board .ib.primary:hover:not(:disabled) { background: var(--b-accent); filter: brightness(1.08); }
.board .ib.logo { font-weight: 800; font-size: 14px; letter-spacing: -.02em; padding: 0 10px; }
.board .ib.logo { display: inline-flex; align-items: center; gap: 7px; }
.board .ib.logo .mark { width: 20px; height: 20px; border-radius: 6px; }
.board .ib.logo .mark svg { width: 12px; height: 12px; }
.board .ib[disabled] { opacity: .4; }
.board .vsep { width: 1px; height: 18px; background: var(--b-line); margin: 0 4px; flex: none; }
.board .btitle { border: none; background: transparent; color: var(--b-ink); font-weight: 600; font-size: 14px; width: 200px; height: 32px;
  padding: 0 6px; border-radius: 8px; }
.board .btitle:hover { background: var(--b-hover); }
.board .btitle:focus { outline: 2px solid var(--b-accent); background: var(--b-bg); }
.board .zpct { min-width: 72px; font-variant-numeric: tabular-nums; }
.board .zpct::after { content: ' ▾'; color: var(--b-muted); }
.lpill { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px;
  padding: 6px 4px; background: var(--b-panel); border: 1px solid var(--b-line); border-radius: 14px; box-shadow: var(--b-shadow); z-index: 12; }
.board .lpill .ib { width: 36px; height: 36px; padding: 0; font-size: 17px; }
.board.ro .lpill { display: none; }
.bpill { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px;
  padding: 4px 6px; background: var(--b-panel); border: 1px solid var(--b-line); border-radius: 14px; box-shadow: var(--b-shadow); z-index: 12; }
.bpill .ib { width: 34px; height: 34px; padding: 0; font-size: 16px; }
.bpill .ib.on { background: var(--b-accent); color: #fff; }
.minimap { position: absolute; right: 12px; bottom: 16px; padding: 4px; background: var(--b-panel); border: 1px solid var(--b-line);
  border-radius: 12px; box-shadow: var(--b-shadow); z-index: 12; transition: right .18s; }
.minimap canvas { display: block; width: 200px; height: 132px; border-radius: 8px; background: var(--b-bg); cursor: pointer; }
.board.pOpen .minimap { right: calc(var(--pw) + 24px); }
.palette { position: absolute; left: 76px; top: 64px; bottom: 96px; width: 300px; overflow: auto; z-index: 20; padding: 10px;
  background: var(--b-panel); border: 1px solid var(--b-line); border-radius: 14px; box-shadow: var(--b-shadow); }
.palette[hidden] { display: none; }
.palette .pal-search { margin-bottom: 6px; background: var(--b-bg); color: var(--b-ink); border-color: var(--b-line); }
.palette .pal-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--b-muted); margin: 12px 4px 4px; }
.palette .pal-item { display: block; width: 100%; text-align: left; border: none; background: none; height: auto; padding: 8px; border-radius: 8px; }
.palette .pal-item:hover { background: var(--b-hover); }
.palette .pal-item b { display: block; font-weight: 600; font-size: 14px; }
.palette .pal-item span { display: block; font-size: 12px; color: var(--b-muted); white-space: normal; }
.selbar { position: absolute; z-index: 15; display: flex; align-items: center; gap: 6px; padding: 4px 6px; background: var(--b-panel);
  border: 1px solid var(--b-line); border-radius: 12px; box-shadow: var(--b-shadow); white-space: nowrap; }
.selbar[hidden] { display: none; }
.selbar button { height: 30px; font-size: 13px; padding: 0 10px; }
.sbhint { font-size: 13px; color: var(--b-muted); padding: 0 6px; }
.popmenu { position: absolute; z-index: 40; min-width: 220px; max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: 1px;
  padding: 6px; background: var(--b-panel); border: 1px solid var(--b-line); border-radius: 12px; box-shadow: var(--b-shadow); }
.popmenu[hidden] { display: none; }
.popmenu button { border: none; background: none; text-align: left; height: 32px; padding: 0 10px; border-radius: 8px; }
.popmenu button:hover:not(:disabled) { background: var(--b-hover); }
.popmenu button:disabled { color: var(--b-muted); opacity: 1; }
.popmenu hr { border: 0; border-top: 1px solid var(--b-line); margin: 4px 2px; }
.popmenu.ov { top: 60px; right: 12px; left: auto; min-width: 200px; }
.popmenu.ov button { display: block; width: 100%; }
.popmenu.ov .ap-box, .popmenu.ov > span { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 6px; }
.hl-modal { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); display: grid; place-items: center; z-index: 60; }
.hl-dlg { background: var(--b-panel); border: 1px solid var(--b-line); border-radius: 14px; padding: 18px; max-width: 380px; box-shadow: var(--b-shadow); }
.hl-dlg p { margin: 0 0 14px; }
.hl-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: absolute; bottom: 76px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--b-ink); color: var(--b-bg);
  padding: 8px 14px; border-radius: 10px; font-size: 13px; max-width: 80%; box-shadow: var(--b-shadow); }
.toast[hidden] { display: none; }

/* панель узла: выезжает поверх холста, закрыта по умолчанию */
.panel { position: absolute; top: 64px; right: 12px; bottom: 12px; width: min(var(--pw), calc(100% - 24px)); z-index: 30; display: flex; flex-direction: column;
  background: var(--b-panel); border: 1px solid var(--b-line); border-radius: 14px; box-shadow: var(--b-shadow); overflow: hidden;
  transform: translateX(calc(100% + 24px)); visibility: hidden; transition: transform .18s ease, visibility .18s; }
.board.pOpen .panel { transform: none; visibility: visible; }
.presize { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 2; }
.phead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--b-line); }
.ptitle { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pclose { border: none; background: none; font-size: 20px; line-height: 1; height: 28px; width: 28px; padding: 0; }
.pbody { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.panel input, .panel textarea, .panel select { background: var(--b-bg); color: var(--b-ink); border-color: var(--b-line); }
.panel .tabs button { height: 30px; }
.panel .tabs button.active { background: var(--b-accent); border-color: var(--b-accent); color: #fff; }
.panel .output { background: var(--b-bg); }
.nset { z-index: 70; background: var(--b-panel); color: var(--b-ink); border-color: var(--b-line); }
.nset input, .board .nset select, .board .nset textarea { background: var(--b-bg); color: var(--b-ink); border-color: var(--b-line); }

/* общие блоки панели узла и всплывающих настроек (перенесены без изменений) */
.nset { position: fixed; z-index: 70; width: 270px; background: var(--b-panel, var(--panel)); border: 1px solid var(--b-line, var(--line)); border-radius: 12px; padding: 12px; box-shadow: var(--b-shadow, var(--shadow)); color: var(--b-ink, var(--ink)); }
.nset label { margin-top: 6px; }
.nset .row { margin-top: 10px; }
.output { white-space: pre-wrap; font-size: 14px; background: var(--bg); border-radius: 8px; padding: 10px; min-height: 120px; max-height: 50vh; overflow: auto; }
.chat .msg { padding: 8px 10px; border-radius: 8px; margin: 6px 0; white-space: pre-wrap; font-size: 14px; }
.chat .msg.user { background: var(--bg); } .chat .msg.assistant { border: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button.active { background: var(--bg); border-color: var(--muted); }

/* Скрытое не показывается, даже если у элемента свой display. */
[hidden] { display: none !important; }
