:root {
  --ink: #17191f;
  --muted: #6d7079;
  --panel: #ffffff;
  --line: #e1e2e6;
  --primary: #5a46e8;
  --primary-dark: #4432c7;
  --danger: #b33232;
  --shadow: 0 14px 38px rgba(20, 22, 30, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #ececf0;
}
* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button, input, textarea, select { font: inherit; }
button, .file-button, .file-tool { user-select: none; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.topbar { height: 64px; display: grid; grid-template-columns: 230px minmax(180px, 1fr) auto; align-items: center; gap: 20px; padding: 0 18px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--ink); color: white; font-weight: 800; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 4px; }
.project-title { justify-self: center; width: min(460px, 100%); }
.project-title input { width: 100%; border: 0; text-align: center; font-size: 17px; font-weight: 650; border-radius: 8px; padding: 8px; background: transparent; color: var(--ink); }
.project-title input:hover, .project-title input:focus { background: #f4f4f6; outline: none; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.button { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; background: white; color: var(--ink); font-weight: 600; }
.button:hover { background: #f4f4f6; }
.button.primary { background: var(--primary); border-color: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.button.ghost { background: transparent; }
.file-button { cursor: pointer; display: inline-block; }
.file-button input, .file-tool input { display: none; }
.workspace { display: grid; grid-template-columns: 92px 1fr 270px; height: calc(100% - 64px); }
.toolbox { background: var(--panel); border-right: 1px solid var(--line); padding: 10px 8px; overflow-y: auto; z-index: 15; }
.section-label { margin: 12px 6px 7px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.tool { width: 100%; min-height: 54px; padding: 7px 3px; border: 0; border-radius: 10px; background: transparent; color: #3d4048; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; cursor: pointer; text-align: center; }
.tool span { font-size: 20px; line-height: 20px; font-weight: 650; }
.tool:hover { background: #f3f2fb; color: var(--primary); }
.tool.active { background: #eeebff; color: var(--primary); }
.viewport { position: relative; overflow: hidden; background-color: #f4f0e8; background-image: radial-gradient(circle at 1px 1px, rgba(20,20,30,.13) 1px, transparent 0); background-size: 22px 22px; cursor: grab; }
.viewport.is-dragging { cursor: grabbing; }
.viewport.connector-mode { cursor: crosshair; }
.stage { width: 6000px; height: 4000px; position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.connector-layer, .nodes-layer { position: absolute; inset: 0; overflow: visible; }
.connector { pointer-events: stroke; cursor: pointer; }
.connector-hit { fill: none; stroke: transparent; stroke-width: 18; pointer-events: stroke; cursor: pointer; }
.connector.selected { filter: drop-shadow(0 0 4px rgba(90,70,232,.75)); }
.canvas-node { position: absolute; display: flex; align-items: stretch; justify-content: stretch; transform-origin: center; min-width: 80px; min-height: 50px; touch-action: none; cursor: move; }
.canvas-node.selected::after { content: ""; position: absolute; inset: -7px; border: 2px solid var(--primary); border-radius: 10px; pointer-events: none; }
.canvas-node.connect-source::after { content: ""; position: absolute; inset: -9px; border: 3px solid #e87527; border-radius: 12px; pointer-events: none; }
.node-surface { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; text-align: center; border-style: solid; }
.shape-rounded { border-radius: 22px; }
.shape-rectangle { border-radius: 2px; }
.shape-ellipse { border-radius: 50%; }
.shape-pill { border-radius: 999px; }
.shape-diamond { transform: rotate(45deg) scale(.72); }
.shape-diamond > .node-content { transform: rotate(-45deg) scale(1.38); }
.shape-none { border-color: transparent !important; background: transparent !important; overflow: visible; }
.node-content { width: 100%; max-height: 100%; padding: 16px; overflow: auto; overflow-wrap: anywhere; }
.node-content.text { white-space: pre-wrap; font-weight: 650; line-height: 1.14; }
.node-content img, .node-content video, .node-content iframe, .node-content object { width: 100%; height: 100%; object-fit: contain; border: 0; display: block; }
.node-content.media { padding: 0; overflow: hidden; }
.node-content audio { width: calc(100% - 24px); }
.url-card, .file-card { display: flex; width: 100%; height: 100%; padding: 18px; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.url-card .url-icon, .file-card .file-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: rgba(90,70,232,.12); color: var(--primary); font-size: 22px; font-weight: 800; }
.url-card strong, .file-card strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url-card small, .file-card small { color: #6b6d75; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resize-handle { position: absolute; right: -10px; bottom: -10px; width: 20px; height: 20px; border: 3px solid white; border-radius: 50%; background: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,.2); cursor: nwse-resize; display: none; }
.canvas-node.selected .resize-handle { display: block; }
.canvas-help { position: absolute; left: 18px; bottom: 18px; max-width: 440px; background: rgba(20,22,29,.82); color: white; padding: 9px 12px; border-radius: 9px; font-size: 12px; pointer-events: none; opacity: .85; }
.zoom-controls { position: absolute; right: 18px; bottom: 18px; display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: 0 5px 18px rgba(20,22,30,.12); }
.zoom-controls button { border: 0; border-right: 1px solid var(--line); background: white; padding: 9px 11px; font-weight: 650; }
.zoom-controls button:last-child { border-right: 0; }
.zoom-controls button:hover { background: #f2f2f5; }
.inspector { background: var(--panel); border-left: 1px solid var(--line); padding: 10px 14px 24px; overflow-y: auto; z-index: 15; }
.inspector label { display: block; color: #555861; font-size: 12px; font-weight: 650; margin: 10px 0; }
.inspector input:not([type="range"]):not([type="checkbox"]), .inspector select, .inspector textarea { width: 100%; margin-top: 5px; border: 1px solid #d8d9de; border-radius: 8px; padding: 8px; background: white; color: var(--ink); }
.inspector input[type="color"] { height: 36px; padding: 3px !important; }
.inspector textarea { resize: vertical; }
.inspector-head { display: flex; justify-content: space-between; align-items: center; }
.danger-link { border: 0; background: transparent; color: var(--danger); font-size: 12px; font-weight: 700; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.range-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.range-row input { min-width: 0; flex: 1; }
.range-row output { width: 48px; color: var(--muted); text-align: right; font-size: 11px; }
.checkbox { display: flex !important; align-items: center; gap: 7px; }
.stack-actions { display: flex; gap: 7px; margin-top: 14px; }
.stack-actions .button { flex: 1; padding: 7px 5px; font-size: 11px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.path-panel { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 4px; }
.path-list { list-style: none; padding: 0; margin: 4px 0; counter-reset: path; }
.path-list li { counter-increment: path; display: flex; align-items: center; gap: 7px; border-radius: 8px; padding: 6px; font-size: 12px; cursor: pointer; }
.path-list li:hover { background: #f3f3f5; }
.path-list li::before { content: counter(path); display: grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; background: #ece9ff; color: var(--primary); font-weight: 800; }
.path-list li span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.path-list li button { border: 0; background: transparent; color: var(--muted); }
.presentation-bar { position: fixed; z-index: 100; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; background: rgba(16,18,24,.9); color: white; padding: 8px; border-radius: 14px; box-shadow: var(--shadow); }
.presentation-bar[hidden] { display: none; }
.presentation-bar div { display: flex; align-items: center; gap: 9px; }
.presentation-bar button { border: 0; border-radius: 8px; background: rgba(255,255,255,.12); color: white; padding: 8px 11px; }
.presentation-bar span { min-width: 90px; text-align: center; font-size: 12px; }
body.presentation .topbar, body.presentation .toolbox, body.presentation .inspector, body.presentation .zoom-controls, body.presentation .canvas-help { display: none; }
body.presentation .workspace { grid-template-columns: 1fr; height: 100%; }
body.presentation .viewport { grid-column: 1; background-image: none; cursor: default; }
body.presentation .canvas-node { cursor: zoom-in; }
body.presentation .canvas-node.focused { cursor: zoom-out; }
body.presentation .canvas-node.selected::after, body.presentation .resize-handle { display: none; }
dialog { border: 0; padding: 0; border-radius: 16px; box-shadow: var(--shadow); width: min(460px, calc(100% - 30px)); }
dialog::backdrop { background: rgba(10,12,18,.46); backdrop-filter: blur(3px); }
dialog form, .dialog-body { padding: 22px; }
dialog h2 { margin: 0 0 18px; font-size: 20px; }
dialog label { display: block; font-size: 12px; font-weight: 650; color: #555861; margin: 13px 0; }
dialog input { width: 100%; padding: 10px; margin-top: 5px; border: 1px solid #d8d9de; border-radius: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dialog-title { display: flex; align-items: center; justify-content: space-between; }
.dialog-title h2 { margin: 0; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f0f0f3; font-size: 20px; }
.projects-list { margin-top: 16px; display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.project-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 10px; }
.project-row strong, .project-row small { display: block; }
.project-row small { color: var(--muted); margin-top: 3px; }
.project-row button { border: 0; border-radius: 7px; padding: 7px 9px; }
.project-row .load-project { background: #ece9ff; color: var(--primary); font-weight: 700; }
.project-row .delete-project { background: transparent; color: var(--danger); }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #17191f; color: white; padding: 10px 14px; border-radius: 9px; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 980px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .brand small, .top-actions .ghost { display: none; }
  .workspace { grid-template-columns: 76px 1fr 230px; }
}
@media (max-width: 720px) {
  .topbar { height: 56px; padding: 0 10px; gap: 8px; }
  .brand div { display: none; }
  .project-title input { text-align: left; font-size: 14px; }
  .workspace { height: calc(100% - 56px); grid-template-columns: 64px 1fr; }
  .toolbox { padding: 6px 4px; }
  .tool { font-size: 9px; min-height: 48px; }
  .tool span { font-size: 17px; }
  .inspector { position: absolute; right: 0; top: 56px; bottom: 0; width: min(270px, 84vw); transform: translateX(100%); transition: .2s ease; box-shadow: var(--shadow); }
  .inspector.mobile-open { transform: translateX(0); }
  .top-actions { gap: 4px; }
  .top-actions .primary { padding: 8px; }
}
