:root {
  color-scheme: dark;
  --bg: #121316;
  --panel: #17181c;
  --line: #292b31;
  --text: #edeef2;
  --muted: #a0a2ad;
  --faint: #797c88;
  --amber: #f59e0b;
  --node-width: 252px;
  font: 14px/1.42 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, #canvas:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
button:not(:disabled):hover { color: #fff; }
[hidden] { display: none !important; }
.icon { width: 16px; height: 16px; display: inline-block; flex: 0 0 auto; vertical-align: middle; }
[data-icon] > .icon { pointer-events: none; }
.topbar { height: 68px; display: flex; align-items: center; gap: 13px; padding: 0 22px; background: #18191d; border-bottom: 1px solid var(--line); position: relative; z-index: 2; }
.brand { display: flex; align-items: center; gap: 9px; padding: 0; font-size: 23px; font-weight: 750; letter-spacing: -.85px; }
.brand-icon { display: grid; place-items: center; width: 32px; height: 32px; background: var(--amber); color: #241802; border-radius: 8px; }
.brand-icon .icon { width: 20px; height: 20px; }
.brand-period { color: var(--amber); }
.top-divider, .toolbar-divider { height: 23px; width: 1px; background: #32343b; flex-shrink: 0; }
.top-divider { margin: 0 4px 0 6px; }
.project-path { display: inline-flex; gap: 7px; align-items: center; color: var(--muted); padding: 4px 1px; white-space: nowrap; }
.breadcrumb { color: #6f727e; }
.breadcrumb .icon { width: 13px; }
#project-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22vw; }
.modes { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 3px; padding: 4px; border-radius: 9px; background: #111216; border: 1px solid #282a31; }
.modes button { display: flex; align-items: center; gap: 8px; border-radius: 6px; padding: 6px 13px; color: var(--muted); font-size: 13px; font-weight: 550; white-space: nowrap; }
.modes button.active { background: #292b31; color: #fff; box-shadow: 0 1px 2px #0005; }
.modes button.active .icon { color: var(--amber); }
.export-button, .primary { margin-left: auto; height: 35px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: #f8c978; border: 1px solid #6d4b21; background: #302519; border-radius: 7px; font-weight: 650; font-size: 13px; white-space: nowrap; }
.export-button:not(:disabled):hover, .primary:not(:disabled):hover { background: #49341b; color: #ffd994; }
.editor { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: calc(100dvh - 68px); min-height: 420px; }
.sidebar { display: flex; flex-direction: column; padding: 22px 15px 12px; border-right: 1px solid var(--line); background: var(--panel); min-height: 0; }
.sidebar-heading { display: flex; align-items: center; gap: 9px; padding: 0 4px; }
.sidebar-heading > span { color: var(--amber); }
.sidebar-heading h1 { margin: 0; font-size: 15px; font-weight: 650; }
.search { display: flex; align-items: center; gap: 8px; margin: 16px 0 21px; padding: 0 10px; height: 35px; flex-shrink: 0; border: 1px solid #30323a; background: #111216; color: var(--faint); border-radius: 7px; }
.search:focus-within { border-color: var(--amber); }
.search input { width: 100%; background: none; border: 0; outline: none; font-size: 13px; }
.search input:focus-visible { outline: none; }
.search input::placeholder { color: #838694; }
.library { min-height: 0; overflow: auto; padding-bottom: 12px; }
.library-heading { margin: 0 0 9px 3px; color: var(--faint); font-size: 12px; font-weight: 650; }
.library-item { width: 100%; min-height: 62px; border-radius: 8px; border: 1px solid #2b2d34; background: #1e2025; display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 8px 8px 9px; text-align: left; }
.library-item:hover { border-color: color-mix(in srgb, var(--accent) 65%, #292b31); background: #25272d; }
.tile-icon { display: grid; place-items: center; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, #17181c); border: 1px solid color-mix(in srgb, var(--accent) 27%, #1a1b20); width: 33px; height: 33px; flex: 0 0 auto; border-radius: 7px; }
.tile-text { flex: 1; min-width: 0; }
.tile-text strong { display: block; font-size: 13px; font-weight: 630; }
.tile-text small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.tile-add { color: #848794; }
.tile-add .icon { width: 13px; height: 13px; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--line); padding: 10px 0 0; display: grid; gap: 2px; }
.sidebar-bottom button { color: var(--muted); padding: 8px 6px; display: flex; gap: 9px; align-items: center; text-align: left; font-size: 13px; border-radius: 5px; }
.sidebar-bottom button:hover { background: #25272d; }
.workbench { min-height: 0; display: grid; grid-template-rows: 52px minmax(0, 1fr) 31px; }
.toolbar { min-width: 0; display: flex; align-items: center; padding: 0 15px 0 18px; gap: 15px; background: #17181c; border-bottom: 1px solid #2b2d34; }
.sheet { display: flex; align-items: center; gap: 8px; font-weight: 630; white-space: nowrap; }
.sheet .icon { color: var(--amber); }
.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.toolset { display: flex; gap: 3px; }
.icon-btn { color: var(--muted); display: grid; place-items: center; width: 31px; height: 31px; border-radius: 5px; padding: 0; }
.icon-btn:not(:disabled):hover, .icon-btn.active { background: #282a31; }
.icon-btn.active { color: var(--amber); }
.outline-btn { border: 1px solid #353740; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 6px 9px; color: #d5d6de; font-size: 13px; font-weight: 550; white-space: nowrap; }
.outline-btn:not(:disabled):hover { background: #282a31; }
.canvas { position: relative; overflow: hidden; isolation: isolate; touch-action: none; background-color: #121316; background-image: radial-gradient(circle, #353740 1px, transparent 1.15px); background-size: var(--grid, 22px) var(--grid, 22px); background-position: var(--grid-x, 0) var(--grid-y, 0); }
.canvas.is-pan { cursor: grab; }
.canvas.is-drag { cursor: grabbing; }
.world { position: absolute; inset: 0 auto auto 0; width: 0; height: 0; transform-origin: 0 0; }
.wires { overflow: visible; position: absolute; width: 1px; height: 1px; pointer-events: none; z-index: 1; }
.wire { fill: none; stroke: #7c818f; stroke-width: 2.15; }
.wire.is-selected { stroke: var(--amber); stroke-width: 2.6; }
.wire.draft { stroke: var(--amber); stroke-dasharray: 5 4; }
.wire-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.wire-hit:hover + .wire { stroke: #c8cbd5; }
#nodes { position: absolute; }
.node { position: absolute; width: var(--node-width); border: 1px solid color-mix(in srgb, var(--accent) 40%, #1c1e24); border-radius: 12px; background: color-mix(in srgb, var(--accent) 9%, #15171b); box-shadow: 0 8px 24px #0004; user-select: none; }
.node:hover { outline: 2px solid #fff; outline-offset: -1px; z-index: 2; }
.node.selected { outline: 2px solid var(--amber); outline-offset: -1px; z-index: 3; }
.node-header { display: flex; align-items: center; gap: 8px; min-height: 40px; border-radius: 11px 11px 0 0; padding: 0 9px 0 12px; color: white; background: color-mix(in srgb, var(--accent) 66%, #141824); cursor: grab; }
.node-header > .icon { width: 16px; height: 16px; }
.node-header .node-title { font-size: 14px; font-weight: 690; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.node-button { display: grid; place-items: center; padding: 0; width: 24px; height: 26px; border-radius: 5px; color: #fff; flex: 0 0 auto; }
.node-button:hover { background: #0004; }
.node-button[aria-pressed="false"] { color: #241a23; }
.node-body { padding: 11px 12px 12px; }
.node-desc { overflow-wrap: anywhere; color: #bbc0ce; font-size: 12px; margin: 0 0 9px; min-height: 17px; }
.value-wrap { position: relative; min-width: 0; height: 34px; }
.value { width: 100%; height: 100%; background: #101116; color: #f2f3f6; border: 1px solid #090a0d; border-radius: 6px; padding: 5px 9px; font: 600 13px/1.25 ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.value-wrap.unit-present input { padding-right: 55px; }
.value-unit { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: #a7aaba; pointer-events: none; font-size: 12px; }
.value.linked { display: flex; align-items: center; gap: 6px; border-color: color-mix(in srgb, var(--accent) 27%, #22242c); background: color-mix(in srgb, var(--accent) 8%, #171a22); }
.value.linked .icon { width: 13px; height: 13px; color: var(--accent); }
.value.error { color: #ff9caf; font-size: 11px; }
.port { position: absolute; z-index: 2; width: 12px; height: 12px; top: 50%; transform: translateY(-50%); background: #15161a; border: 2px solid var(--accent); border-radius: 50%; padding: 0; }
.port::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; }
.port:hover, .port.armed { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.port.in { left: -19px; }
.port.out { right: -19px; }
.port.math-out { left: auto; right: -19px; }
.node-type { display: block; color: #afb2c1; margin: 0 0 4px; font-size: 11.5px; }
.math-body { display: grid; gap: 10px; }
.math-row { min-width: 0; }
.operation-field { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.operation-field select { appearance: none; width: 100%; font-size: 14px; font-weight: 690; border: 0; border-radius: 5px; background: transparent; cursor: pointer; padding: 5px 21px 5px 2px; }
.operation-field option { background: #242733; color: white; }
.operation-field > .icon { position: absolute; right: 5px; transform: rotate(90deg); pointer-events: none; width: 12px; height: 12px; }
.math-result { color: #d5e2ff; display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 2px; padding-top: 9px; border-top: 1px solid color-mix(in srgb, var(--accent) 26%, #1b1e2a); font-size: 12px; position: relative; }
.math-result strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; text-align: right; }
.math-result .port { top: calc(50% + 4px); }
.frame { position: absolute; border: 1px solid color-mix(in srgb, var(--accent) 33%, #1c1e24); border-radius: 12px; background: color-mix(in srgb, var(--accent) 3.5%, transparent); pointer-events: none; }
.frame.selected { border: 2px solid var(--amber); }
.frame-label { position: absolute; left: 12px; top: 9px; display: inline-flex; align-items: center; gap: 7px; padding: 3px 8px; border-radius: 5px; background: color-mix(in srgb, var(--accent) 12%, #16181f); color: #bfcce6; font-size: 12px; font-weight: 650; white-space: nowrap; pointer-events: auto; cursor: grab; }
.frame-label .icon { color: var(--accent); width: 13px; height: 13px; }
.frame-label button { padding: 0 0 0 2px; color: #acb4c9; }
#marquee { position: absolute; z-index: 4; pointer-events: none; border: 1px solid var(--amber); background: #f59e0b20; }
.zoom { position: absolute; bottom: 17px; left: 17px; z-index: 5; display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid #33353e; background: #1d1f24; border-radius: 8px; box-shadow: 0 4px 14px #0004; }
.zoom-value { min-width: 49px; font-size: 12px; font-weight: 650; }
.zoom > span { width: 1px; height: 19px; background: #373941; margin: 0 2px; }
.minimap { position: absolute; bottom: 17px; right: 17px; z-index: 5; width: 143px; height: 78px; background: #181a20; border: 1px solid #363943; border-radius: 8px; padding: 5px; overflow: hidden; box-shadow: 0 4px 14px #0004; }
.minimap:hover { border-color: #6c7284; }
.minimap canvas { width: 100%; height: 100%; }
.canvas-hint { position: absolute; bottom: 29px; left: 50%; transform: translateX(-50%); color: #9395a2; font-size: 12px; pointer-events: none; text-align: center; white-space: nowrap; }
.statusbar { padding: 0 15px 0 18px; display: flex; align-items: center; justify-content: space-between; background: #17181c; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.ready { display: flex; align-items: center; gap: 7px; }
.ready i { width: 6px; height: 6px; background: #2ac89b; border-radius: 50%; }
#empty-canvas { position: absolute; left: 50%; top: 43%; transform: translate(-50%, -50%); text-align: center; max-width: 340px; pointer-events: none; }
#empty-canvas .icon { height: 29px; width: 29px; color: var(--amber); margin-bottom: 8px; }
#empty-canvas strong { display: block; font-size: 18px; }
#empty-canvas p { color: var(--muted); }
.page { max-width: 1100px; margin: 0 auto; padding: 49px 28px; }
.page h1 { font-size: clamp(28px, 4vw, 42px); margin: 3px 0; line-height: 1.16; letter-spacing: -.035em; }
.page .lede { color: var(--muted); margin: 10px 0 0; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.page-actions button { min-height: 37px; margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 15px; }
.project-card, .calc-panel { text-align: left; border: 1px solid #30323b; border-radius: 13px; background: #1a1c21; padding: 20px; }
.project-card:hover { border-color: var(--amber); background: #22232a; }
.project-card .tile-icon { margin-bottom: 16px; }
.project-card strong { display: block; font-size: 17px; margin-bottom: 4px; overflow-wrap: anywhere; }
.project-card small { color: var(--muted); }
.calculator { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.calc-panel h2 { margin: 0 0 19px; font-size: 18px; display: flex; gap: 9px; align-items: center; }
.calc-panel h2 .icon { color: var(--accent); }
.calc-field { padding: 14px 0; border-top: 1px solid #30323b; }
.calc-field strong, .calc-field label { display: block; font-weight: 630; font-size: 15px; }
.calc-field p { color: var(--muted); margin: 4px 0 9px; min-height: 1lh; }
.calc-field output { color: #5ae3b7; font-size: clamp(20px, 3vw, 35px); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; font-weight: 710; letter-spacing: -.025em; }
.calc-field .value-wrap { height: 42px; }
.calc-field .value { font-size: 15px; }
.page-empty { color: var(--muted); }
dialog { border: 1px solid #3d404a; border-radius: 13px; background: #202227; color: var(--text); padding: 22px; width: min(410px, 90vw); box-shadow: 0 20px 80px #0008; }
dialog::backdrop { background: #090a0db8; }
dialog h2 { font-size: 20px; margin: 0 0 15px; }
dialog label { display: grid; gap: 4px; margin-bottom: 12px; color: #c9cbd4; }
dialog input { min-height: 34px; width: 100%; background: #131419; border: 1px solid #3e414b; border-radius: 6px; padding: 5px 8px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.dialog-actions .primary { margin: 0; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 25px; height: 25px; border: 2px solid transparent; border-radius: 50%; background: var(--swatch); }
.swatch[aria-pressed="true"] { border-color: #fff; }
.help-list { padding-left: 19px; color: #d2d3dc; }
.help-list li { margin-bottom: 8px; }
kbd { padding: 1px 5px; border: 1px solid #454852; border-radius: 4px; background: #16181d; }
#toast { position: fixed; z-index: 8; bottom: 46px; right: 18px; max-width: min(400px, 85vw); padding: 10px 14px; background: #25272f; border: 1px solid #474a56; border-left: 3px solid var(--amber); border-radius: 8px; box-shadow: 0 8px 24px #0007; }
@media (max-width: 1050px) {
  .topbar { gap: 8px; padding-inline: 14px; }
  .project-path span:last-child, .breadcrumb { display: none; }
  #project-name { max-width: 19vw; }
  .editor { grid-template-columns: 215px minmax(0, 1fr); }
  .sidebar { padding-inline: 11px; }
}
@media (max-width: 720px) {
  .topbar { height: 101px; padding-bottom: 42px; }
  .modes { bottom: 7px; }
  #project-name { max-width: 28vw; }
  .editor { height: calc(100dvh - 101px); grid-template-columns: 61px minmax(0, 1fr); }
  .sidebar { padding: 12px 7px 8px; }
  .sidebar-heading { justify-content: center; }
  .sidebar-heading h1, .search, .tile-text, .tile-add, .library-heading, .canvas-hint { display: none; }
  .library { margin-top: 13px; }
  .library-item { justify-content: center; min-height: 44px; padding: 3px; }
  .sidebar-bottom button { width: 34px; overflow: hidden; white-space: nowrap; }
  .toolbar { gap: 4px; padding-inline: 6px; }
  .sheet span:last-child, .group-action .action-label { display: none; }
  .tools { gap: 3px; }
  .minimap { width: 95px; height: 56px; }
  .page { padding: 26px 15px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .calculator { grid-template-columns: 1fr; }
}
#nodes { z-index: 2; }
.frame:has(.frame-label:hover) { outline: 2px solid #fff; outline-offset: -1px; }
.frame.selected:has(.frame-label:hover) { outline-color: var(--amber); }
.operation-symbol { width: 16px; flex: 0 0 auto; text-align: center; font-size: 19px; font-weight: 700; line-height: 1; }
.value.linked > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-present .value.linked { padding-right: 36px; }
.calc-field > .value-wrap { margin-top: 8px; }
