:root {
  --stage: #4f5250; --box: rgba(28, 31, 30, .95); --ink: #eef1ef; --muted: #a3aca6; --line: #3c423f;
  --accent: #4caf73; --accent-ink: #0d1510; --warn: #f0965a; --field: #2a2f2c; --hot: #7fd6a0;
  --blk: #f4f5f2; --blk-ink: #1d2320; --blk-line: #c9cfca; --sel: #4caf73;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--stage); color: var(--ink); font: 14px/1.4 "Segoe UI", system-ui, sans-serif; }
button { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent); cursor: pointer; white-space: nowrap; background: transparent; color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.icon { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; border-radius: 10px; }
button.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
button.icon svg .fill { fill: currentColor; stroke: none; }
button.icon:not(:disabled):hover { background: var(--field); }
button.icon.primary:not(:disabled):hover { background: #5cc184; }
button.icon.busy svg { animation: pulse .8s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .35; } }
button.danger { border-color: var(--warn); color: var(--warn); margin-top: 16px; width: 100%; }
button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- palco */
#stage { position: fixed; inset: 0; bottom: var(--bar-h, 96px); user-select: none; overflow: hidden; }
#placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #d9ddda; text-align: center; padding: 24px; pointer-events: none; }
#placeholder p { max-width: 460px; margin: 0; opacity: .85; }
.zl-in, .zl-out, .ze-in, .ze-out { opacity: 0; }
.ed-canvas { transition: transform .32s cubic-bezier(.4,0,.2,1), opacity .32s; }
.zl-in { transform: scale(2.6); } .ze-in { transform: scale(.55); transition: none !important; }
.zl-out { transform: scale(.6); } .ze-out { transform: scale(1.8); transition: none !important; }

/* ---------- editor de blocos */
.ed-canvas { position: absolute; inset: 0; outline: none; cursor: grab;
  background-image: radial-gradient(circle, rgba(255,255,255,.09) 1px, transparent 1.2px); background-size: 20px 20px; }
.ed-canvas:active { cursor: grabbing; }
.ed-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.ed-wires { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; }
.wire { fill: none; stroke-width: 3; opacity: .95; pointer-events: none; }
.wire.sel { stroke-width: 5.5; filter: drop-shadow(0 0 4px #fff); }
.wire.temp { stroke-dasharray: 7 6; }
.marquee { position: absolute; border: 1.5px dashed var(--accent); background: rgba(76,175,115,.12); border-radius: 4px; pointer-events: none; z-index: 4; }
.wire-hit { fill: none; stroke: transparent; stroke-width: 14; cursor: pointer; pointer-events: stroke; }
.blk { position: absolute; background: var(--blk); color: var(--blk-ink); border: 1px solid var(--blk-line); border-radius: 10px; box-shadow: 0 3px 10px rgba(0,0,0,.25); cursor: move; }
.blk.sel { outline: 3px solid var(--sel); outline-offset: 2px; }
.blk.note { --nb: #fff4b0; background: var(--nb); color: #3b3a2e; border: 1px solid rgba(0,0,0,.12); border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,.28); }
.blk.note.note-blue { --nb: #d9ecff; } .blk.note.note-green { --nb: #dcf3e1; } .blk.note.note-pink { --nb: #ffe0e8; } .blk.note.note-gray { --nb: #eceff1; }
.note-text { padding: 11px 12px; font: 13px/18px "Segoe UI", system-ui, sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-text.empty { color: rgba(0,0,0,.42); font-style: italic; }
.note-edit { display: block; width: 100%; min-height: 46px; box-sizing: border-box; border: 0; margin: 0; padding: 11px 12px; background: transparent; color: inherit; resize: none; overflow: hidden; font: 13px/18px "Segoe UI", system-ui, sans-serif; outline: 2px solid var(--accent); border-radius: 4px; cursor: text; }
/* alça de largura: faixa na borda direita com tamanho constante na tela (--iz = 1/zoom) */
.note-resize { position: absolute; top: 0; bottom: 0; right: calc(-7px * var(--iz, 1)); width: calc(14px * var(--iz, 1)); cursor: ew-resize; }
.note-resize::after { content: ''; position: absolute; right: calc(7px * var(--iz, 1)); bottom: 0; width: calc(12px * var(--iz, 1)); height: calc(12px * var(--iz, 1)); background: linear-gradient(135deg, transparent 55%, rgba(0,0,0,.3) 55%); border-bottom-right-radius: 4px; }
.note-panel-text { width: 100%; box-sizing: border-box; background: var(--field); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 13px/18px "Segoe UI", system-ui, sans-serif; resize: vertical; margin-bottom: 10px; }
/* blocos de exportação (CSV, Excel, PDF): ícone, e embaixo a mensagem ou o botão Baixar */
.blk.exp .blk-icon { height: calc(100% - 88px); }
.blk-exp { position: absolute; left: 8px; right: 8px; bottom: 8px; height: 30px; display: flex; align-items: center; justify-content: center; }
.exp-msg { color: #7a857e; font-size: 11px; line-height: 13px; text-align: center; }
.exp-dl { width: 100%; height: 30px; padding: 0 8px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); }
.exp-dl:not(:disabled):hover { background: #5cc184; }
.exp-dl svg, .exp-dl-big svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.exp-opts { display: flex; flex-direction: column; gap: 7px; font-size: 13px; }
.exp-chk { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.exp-chk input { width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--accent); flex: none; }
.exp-field { display: flex; flex-direction: column; gap: 3px; }
.exp-field > span { color: var(--muted); font-size: 12px; }
.exp-src { margin: 0; padding-left: 18px; font-size: 13px; }
.exp-dl-big { width: 100%; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; }
/* bloco Código Rust: painel com o código, constantes e guia de exemplos */
.rust-code { width: 100%; box-sizing: border-box; min-height: 230px; resize: vertical; background: #161a18; color: #e6ece8; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 12.5px/1.5 Consolas, "Cascadia Mono", "Courier New", monospace; tab-size: 4; white-space: pre; overflow: auto; }
.rust-code:focus { outline: 1px solid var(--accent); }
.rust-check { margin: 4px 0 0; font-size: 12px; }
.rust-fields { display: grid; grid-template-columns: 70px 1fr; gap: 6px 8px; align-items: center; font-size: 13px; }
.rust-fields > span { color: var(--muted); }
.rust-consts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.rust-consts label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font: 12px Consolas, monospace; }
.rust-consts input { min-width: 0; }
.rust-ins { margin: 0; padding-left: 18px; font-size: 13px; }
.rust-panel code { font-family: Consolas, "Courier New", monospace; color: var(--hot); }
.rust-panel details > summary { cursor: pointer; font-weight: 600; margin: 14px 0 6px; }
.rust-ref .kv { grid-template-columns: 72px 1fr; }
.rust-example { border-top: 1px solid var(--line); padding: 8px 0; }
.rust-example > p { margin: 3px 0; }
.rust-example pre, .memo-code { margin: 6px 0; padding: 8px 10px; background: #161a18; color: #e6ece8; border-radius: 8px; font: 12px/1.45 Consolas, "Courier New", monospace; overflow-x: auto; white-space: pre; }
.blk.composite { background: #e6efe9; border: 2px solid #8bbf9c; cursor: zoom-in; }
.blk.boundary { background: transparent; border: 2px dashed #b9c2bc; color: var(--ink); box-shadow: none; }
.blk-label { font-size: 12px; font-weight: 600; padding: 6px 10px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk-icon { display: block; margin: 4px auto 0; width: calc(100% - 28px); height: calc(100% - 52px); object-fit: contain; pointer-events: none; }
.blk-noicon { display: grid; place-items: center; font-weight: 700; color: #7a857e; text-transform: uppercase; }
.blk-open { position: absolute; right: 8px; top: 4px; font-size: 13px; color: #4c8f62; }
.blk.viz { background: #fbfcfa; cursor: move; }
.blk-viz { position: absolute; left: 8px; right: 8px; top: 30px; bottom: 8px; display: flex; align-items: stretch; }
.blk-viz svg { display: block; }
.viz-msg { margin: auto; color: #7a857e; font-size: 12px; text-align: center; padding: 0 10px; }
.viz-big { background: #f4f5f2; border-radius: 8px; padding: 8px; height: 260px; color: #1d2320; }
/* título "Gráfico" + gráfico ampliado: ficam à vista enquanto as opções de Aparência rolam embaixo */
.viz-head { padding-top: 14px; background: #1f2221; }   /* --box sem transparência, para o que rola por baixo não aparecer */
#panel .viz-head h3 { margin-top: 0; }
@media (min-height: 700px) { .viz-head { position: sticky; top: -16px; z-index: 2; padding-bottom: 6px; } }
details.viz-style { margin-top: 10px; border-top: 1px solid var(--line); }
details.viz-style > summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); padding: 10px 0 6px; }
details.viz-style > summary:hover { color: var(--ink); }
.vs { display: grid; grid-template-columns: 1fr 150px; gap: 6px 8px; align-items: center; font-size: 13px; }
.vs label { color: var(--muted); }
.vs h4 { grid-column: 1 / -1; margin: 8px 0 0; font-size: 12px; font-weight: 600; color: var(--ink); }
.vs input[type=checkbox] { width: 18px; height: 18px; justify-self: start; margin: 0; }
.vs-wide { grid-column: 1 / -1; }
.vs-series { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 44px 30px; gap: 6px; align-items: center; }
.vs-series input[type=color] { padding: 2px; height: 31px; cursor: pointer; }
.vs-reset { padding: 4px 0; }
.vs-foot { margin: 12px 0 4px; }
/* painel de gráficos (chart_panel): lista de gráficos no painel lateral, cada um com prévia e opções */
.cp-add { display: flex; gap: 6px; margin: 2px 0 8px; }
.cp-add select { flex: 1; min-width: 0; }
.cp-add button { padding: 6px 12px; }
.cp-card { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; }
.cp-card[open] { padding-bottom: 8px; }
.cp-card > summary { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 10px; cursor: pointer; font-size: 13px; list-style: none; }
.cp-card > summary::-webkit-details-marker { display: none; }
.cp-card > summary::before { content: '▸'; color: var(--muted); font-size: 11px; transition: transform .15s; }
.cp-card[open] > summary::before { transform: rotate(90deg); }
.cp-card > summary:hover .cp-name { color: var(--accent); }
.cp-card > :not(summary) { margin-left: 10px; margin-right: 10px; }
.cp-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cp-tools { display: flex; gap: 3px; }
.cp-tool { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line); color: var(--muted); border-radius: 7px; font-size: 13px; line-height: 1; }
.cp-tool:not(:disabled):hover { color: var(--ink); border-color: var(--muted); }
.cp-prev { background: #f4f5f2; border-radius: 8px; padding: 3px; margin-bottom: 8px; box-sizing: content-box; }
.cp-prev svg { display: block; }
.cp-ser { grid-column: 1 / -1; display: grid; gap: 5px; padding: 6px; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 8px; }
.cp-ser-1 { display: grid; grid-template-columns: 1fr 112px; gap: 6px; }
.cp-btns { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.cp-btns button { padding: 5px 10px; font-size: 12.5px; }
.cp-card details.viz-style { margin-top: 8px; }
.wire.sig { stroke-dasharray: 6 5; stroke-width: 2.2; }
.blk-badge { position: absolute; left: -2px; right: -2px; top: calc(100% + 6px); text-align: center; font-size: 11.5px; font-weight: 600; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.blk-badge.util::after, .blk-badge.full::after { content: ""; display: block; height: 4px; margin: 3px 10px 0; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) var(--util), rgba(255,255,255,.15) var(--util)); }
.blk-badge.full { color: #ffd27a; }
.blk-badge.full::after { background: linear-gradient(90deg, #e0a24f var(--util), rgba(255,255,255,.15) var(--util)); }
.blk-badge.idle { color: var(--muted); font-weight: 400; }
.blk-badge.stale { opacity: .45; }
.port { position: absolute; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: var(--pc); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); cursor: crosshair; z-index: 2; }
.port.in { cursor: default; }
.ed-canvas.wiring .port.no { opacity: .25; }
.ed-canvas.wiring .port.ok { transform: scale(1.45); box-shadow: 0 0 0 3px var(--pc); }
.ed-palette { position: absolute; left: 14px; top: 14px; bottom: 14px; width: 218px; display: flex; flex-direction: column; background: var(--box); border: 1px solid var(--line); border-radius: 12px; padding: 10px; z-index: 3; }
.ed-palette.min { bottom: auto; width: 218px; }
.ed-palette.min .pal-search, .ed-palette.min .pal-list, .ed-palette.min .pal-hint { display: none; }
.pal-head { display: flex; align-items: center; gap: 6px; margin: 0 0 8px 4px; }
.ed-palette.min .pal-head { margin-bottom: 0; }
.pal-title { flex: 1; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.pal-toggle { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line); color: var(--muted); border-radius: 7px; display: grid; place-items: center; }
.pal-toggle:hover { color: var(--ink); border-color: var(--muted); }
.pal-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.ed-palette.min .pal-toggle svg { transform: rotate(180deg); }
.pal-info-btn { font: italic 700 13px Georgia, serif; }
.pal-info-btn.on { color: var(--accent); border-color: var(--accent); }
.pal-info { position: absolute; left: calc(100% + 10px); top: 0; width: 300px; background: var(--box); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.45); z-index: 8; max-height: calc(100vh - var(--bar-h, 96px) - 40px); overflow: auto; }
.pal-info-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--accent); margin-bottom: 8px; }
.pal-info dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: 12.5px; }
.pal-info dt { color: var(--ink); font-weight: 600; white-space: nowrap; }
.pal-info dd { margin: 0; color: var(--muted); }
.pal-search { position: relative; margin-bottom: 8px; }
.pal-search input { padding-left: 30px; }
.pal-search svg { position: absolute; left: 9px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.pal-list { flex: 1; overflow: auto; min-height: 0; }
.pal-empty { color: var(--muted); font-size: 12.5px; padding: 8px 6px; }
.pal-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--accent); margin: 10px 6px 2px; padding-top: 6px; border-top: 1px solid var(--line); }
.pal-group:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.pal-item { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 6px; border-radius: 8px; cursor: grab; }
.pal-item:hover { background: var(--field); }
.pal-item img, .pal-item .pal-noicon { grid-row: span 2; width: 40px; height: 34px; object-fit: contain; background: var(--blk); border-radius: 6px; padding: 2px; }
.pal-item > span:nth-of-type(1) { font-size: 13px; line-height: 1.2; }
.pal-ports { display: flex; gap: 4px; }
.pal-ports i { width: 8px; height: 8px; border-radius: 50%; background: var(--pc); display: inline-block; }
.pal-item.disabled { opacity: .35; cursor: not-allowed; }
.pal-ghost { position: fixed; z-index: 50; width: 200px; background: var(--box); border: 1px solid var(--accent); pointer-events: none; }

/* ---------- caixinha (barra embaixo) */
/* a barra encolhe até o conteúdo: os botões e o modelo numa linha, o status embaixo.
   z-index acima do #panel (6): os menus e o dropup de KPIs saem de dentro da barra e
   passariam por baixo do painel lateral aberto (os dois não se sobrepõem, o painel acaba em --bar-h) */
#box { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--box); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.35); z-index: 7; }
.box-row { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; max-width: 100%; }
.btns { display: flex; gap: 8px; }
#modelInfo { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-left: 14px; border-left: 1px solid var(--line); }
#modelInfo .mi-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
#modelInfo .name { font-weight: 600; font-size: 13px; white-space: nowrap; }
#crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; }
#crumbs a { color: var(--accent); cursor: pointer; }
#crumbs a:hover { text-decoration: underline; }
#crumbs .sep { color: var(--muted); }
#kpis { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
#kpis:empty { display: none; }
.kpi { background: var(--field); border-radius: 8px; padding: 4px 9px; }
.kpi.warn { outline: 1px solid var(--warn); }
.kpi .l { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.kpi .v { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi.warn .v { color: var(--warn); }
/* indicadores que não cabem na barra: chip "+N" com dropup de todos eles */
.kpi-dd { display: flex; }
.kpi-more { display: flex; align-items: center; gap: 4px; padding: 5px 8px 5px 9px; border: 1px dashed var(--line); border-radius: 8px;
  background: transparent; color: var(--muted); font-weight: 700; font-size: 12.5px; line-height: 1; }
.kpi-more:not(:disabled):hover { color: var(--ink); border-color: var(--muted); }
.kpi-more.warn { color: var(--warn); border-color: var(--warn); }
.kpi-dd.open > .kpi-more { background: var(--field); border-style: solid; color: var(--ink); }
.kpi-caret { display: grid; place-items: center; }
.kpi-caret svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.kpi-dd.open .kpi-caret svg { transform: rotate(180deg); }
/* o dropup abre acima da caixinha inteira: o `transform` do #box vira o bloco contentor
   do position:fixed, então 100% aqui é a altura da barra (e o popup nunca cobre o conteúdo dela) */
.kpi-pop { display: none; position: fixed; bottom: calc(100% + 8px); left: auto; right: 0; width: min(520px, calc(100vw - 24px));
  max-height: min(50vh, calc(100vh - var(--bar-h, 96px) - 32px)); overflow: auto; background: #232825; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45); z-index: 20; }
.kpi-dd.open > .kpi-pop { display: block; }
.kpi-pop-head { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 8px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(208px, 1fr)); gap: 0 20px; }
.kpi-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,.05); font-size: 12.5px; }
.kpi-line .l { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-line .v { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-line.warn .v { color: var(--warn); }
#status { text-align: center; font-size: 12px; color: var(--muted); white-space: pre-wrap; max-height: 150px; overflow: auto; max-width: 100%; }
#status:empty { display: none; }
#status.err { color: var(--warn); text-align: left; }
#status.warn { color: #ffd27a; }


/* ---------- menus suspensos (abrem para cima, a barra fica embaixo) */
.dd { position: relative; }
button.icon.dd-btn { width: 54px; display: flex; gap: 2px; justify-content: center; }
button.icon.dd-btn .caret { width: 12px; height: 12px; transition: transform .15s; }
.dd.open > .dd-btn { background: var(--field); }
.dd.open > .dd-btn .caret { transform: rotate(180deg); }
.menu { display: none; position: absolute; bottom: calc(100% + 8px); left: 0; min-width: 236px; background: #232825; border: 1px solid var(--line); border-radius: 10px; padding: 5px; box-shadow: 0 10px 30px rgba(0,0,0,.45); z-index: 20; }
.dd.open > .menu { display: block; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-radius: 7px; padding: 8px 10px; background: transparent; color: var(--ink); font-weight: 500; text-align: left; }
.menu button:hover:not(:disabled), .menu .sub:hover > button:not(:disabled), .menu .sub.open > button { background: var(--field); }
.menu button svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.menu button span { flex: 1; }
.menu kbd { font: 11px Consolas, ui-monospace, monospace; color: var(--muted); }
.menu button:disabled { opacity: .4; cursor: not-allowed; }
.menu .sub { position: relative; }
.menu .sub .sub-caret { stroke: var(--muted); width: 14px; height: 14px; }
.menu .sub > .menu { bottom: -6px; left: calc(100% + 4px); }
.menu .sub:hover > .menu, .menu .sub.open > .menu { display: block; }
/* ponte invisível sobre o vão entre o item e o submenu: o mouse não "cai" no caminho */
.menu .sub > .menu::before { content: ''; position: absolute; top: -6px; bottom: -6px; left: -14px; width: 14px; }
.menu .sub > .menu button { padding-left: 14px; }
/* ---------- diálogo */
dialog#dlg { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 60px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: #1f2421; color: var(--ink); box-shadow: 0 20px 50px rgba(0,0,0,.5); }
dialog#dlg::backdrop { background: rgba(0,0,0,.45); }
dialog#dlg header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
dialog#dlg h2 { margin: 0; font-size: 16px; }
dialog#dlg .x { border: 0; color: var(--muted); font-size: 20px; padding: 0 4px; }
#dlgBody { padding: 14px 18px; overflow: auto; max-height: calc(100vh - 200px); }
#dlgFoot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 18px 14px; border-top: 1px solid var(--line); }
#dlgFoot:empty { display: none; }
.form { display: grid; grid-template-columns: 1fr 170px; gap: 10px 14px; align-items: center; font-size: 13px; }
.form label { color: var(--muted); }
.form .hint { grid-column: 1 / -1; color: var(--muted); font-size: 12px; margin-top: -4px; }
.form input[type=checkbox] { width: 18px; height: 18px; justify-self: start; }
.log-entry { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 12.5px; }
.log-entry.err { border-color: var(--warn); }
.log-entry h4 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.log-entry h4 .t { color: var(--muted); font-weight: 400; }
.log-entry .ok { color: var(--accent); } .log-entry .bad { color: var(--warn); }
.log-entry ul { margin: 4px 0 0; padding-left: 18px; }
.log-entry pre { white-space: pre-wrap; font: 11.5px Consolas, ui-monospace, monospace; color: var(--warn); margin: 6px 0 0; }

/* ---------- painel lateral (clique direito) */
#panel { position: fixed; top: 14px; right: 14px; bottom: var(--bar-h, 96px); width: min(380px, calc(100vw - 28px)); background: var(--box); border: 1px solid var(--line); border-radius: 12px; padding: 16px; overflow: auto; z-index: 6; box-shadow: 0 8px 28px rgba(0,0,0,.35); transform: translateX(calc(100% + 24px)); transition: transform .25s; }
#panel.open { transform: none; }
#panel.wide { width: min(560px, calc(100vw - 28px)); }
.blk-label.memo { cursor: pointer; }
.blk-badge.short { color: var(--warn); }
.blk-label.memo:hover { color: var(--accent); text-decoration: underline; }
.memo-item { background: var(--field); border-radius: 8px; padding: 7px 10px; margin: 6px 0; }
.memo-t { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.memo-t b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.memo-f { font-family: Consolas, ui-monospace, monospace; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.memo-scroll { overflow-x: auto; }
.memo-month { margin-top: 12px; }
.memo-month summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 6px; }
.memo-tab { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.memo-tab th { text-align: right; color: var(--muted); font-weight: 600; padding: 3px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.memo-tab td { text-align: right; padding: 2px 6px; border-bottom: 1px solid rgba(255,255,255,.04); white-space: nowrap; }
.memo-tab th:first-child, .memo-tab td:first-child { text-align: left; }
.memo-tab tr.tot td { font-weight: 700; border-top: 1px solid var(--line); }
.memo-tab tr.sub td { color: var(--muted); }
.memo-name { color: var(--accent); cursor: pointer; }
.memo-name:hover { text-decoration: underline; }
.memo-link { margin: 12px 8px 0 0; }
#panel header { display: flex; justify-content: space-between; align-items: start; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 10px; }
#panel h2 { margin: 0; font-size: 17px; }
#panel .cls { font-size: 11px; color: var(--muted); font-family: Consolas, ui-monospace, monospace; }
#panelClose { border: 0; color: var(--muted); font-size: 20px; padding: 0 4px; line-height: 1; }
#panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 14px 0 6px; }
select, input { width: 100%; font: inherit; padding: 6px 8px; border-radius: 7px; background: var(--field); color: var(--ink); border: 1px solid var(--line); }
.params { display: grid; grid-template-columns: 1fr 96px auto; gap: 6px 8px; align-items: center; font-size: 13px; }
.params label { color: var(--muted); }
.params .unit { color: var(--muted); font-size: 12px; white-space: nowrap; }
.params select { grid-column: span 2; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.note { color: var(--muted); font-size: 12.5px; margin: 6px 0; }
.note.warn { color: var(--warn); }
ol.paths, ul.warns { margin: 0; padding-left: 20px; font-size: 12.5px; }
ul.warns { color: var(--warn); }
details.code summary { cursor: pointer; color: var(--accent); margin-top: 14px; font-size: 13px; }
details.code pre { font: 11px/1.45 Consolas, ui-monospace, monospace; background: var(--field); padding: 10px; border-radius: 8px; overflow: auto; max-height: 340px; white-space: pre; user-select: text; }
/* ---------- Enviar / Receber (ligação pelo rótulo) */
.blk.goto { --tc: #cdd5d0; border: 2px solid var(--tc); }
.blk.goto.tag-bad { border-style: dashed; }
.goto-tag { position: absolute; left: 10px; right: 10px; top: 28px; height: 48px; line-height: 48px; padding: 0 8px; border-radius: 8px; text-align: center;
  background: color-mix(in srgb, var(--tc) 26%, transparent); font-size: 20px; font-weight: 700; color: var(--blk-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.goto-tag.empty { font-size: 13px; font-style: italic; color: #a5533a; }
.goto-scope { position: absolute; right: 9px; top: 7px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #4c8f62; }
.blk.tag-mate { outline: 3px dashed var(--sel); outline-offset: 3px; }
.blk.tag-mate-in { outline: 3px dashed var(--hot); outline-offset: 3px; }
.blk.flash { animation: tagflash 1.2s ease-out; }
@keyframes tagflash { 0%, 45% { box-shadow: 0 0 0 9px rgba(76,175,115,.65); } 100% { box-shadow: 0 3px 10px rgba(0,0,0,.25); } }
.params.tagp { grid-template-columns: 64px 1fr; }
.params.tagp select { grid-column: auto; }
.tag-type::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--tc); margin-right: 6px; }
.tag-list { display: grid; gap: 6px; }
.tag-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; background: var(--field); border-radius: 8px; padding: 6px 8px; }
.tag-row span { overflow-wrap: anywhere; }
.tag-go { padding: 3px 12px; font-size: 12px; }
@media (max-width: 700px) { .ed-palette { width: 160px; } #panel { top: auto; height: 60vh; } }
