/* 画布节点/连线由 JS 插入，不能走 Blazor scoped CSS，必须全局。 */
.ai-wf-canvas {
    position: absolute;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    outline: none;
    cursor: default;
    transform-origin: 0 0;
    background:
        radial-gradient(circle at 1px 1px, color-mix(in oklab, var(--ox-text-primary) 10%, transparent) 1px, transparent 0) 0 0 / 16px 16px;
}

.ai-wf-canvas.is-connecting {
    cursor: crosshair;
}

.ai-wf-canvas.is-dragging {
    cursor: grabbing;
}

.ai-wf-edges {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    z-index: 1;
}

.ai-wf-edge {
    fill: none;
    stroke: var(--ox-accent);
    stroke-width: 2.4;
    pointer-events: stroke;
    cursor: pointer;
}

.ai-wf-edge.is-selected {
    stroke: var(--ox-accent-foreground, var(--ox-accent));
    stroke-width: 3;
}

.ai-wf-edge-temp {
    fill: none;
    stroke: var(--ox-accent);
    stroke-width: 2;
    stroke-dasharray: 6 4;
    pointer-events: none;
}

.ai-wf-edge-label {
    fill: var(--ox-muted);
    font-size: var(--ox-fs-caption, 11px);
    pointer-events: none;
}

.ai-wf-nodes {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: visible;
}

.ai-wf-node {
    position: absolute;
    width: 200px;
    min-height: 72px;
    box-sizing: border-box;
    padding: 10px 32px 10px 18px;
    border: 1px solid var(--ox-border);
    border-radius: 8px;
    background: var(--ox-surface);
    box-shadow: 0 1px 2px color-mix(in oklab, var(--ox-text-primary) 8%, transparent);
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.ai-wf-node::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 8px 0 0 8px;
    background: var(--ox-accent);
}

.ai-wf-node.is-type-start::before { background: var(--ox-status-on, #16a34a); }
.ai-wf-node.is-type-end::before { background: var(--ox-muted); }
.ai-wf-node.is-type-condition::before { background: #d97706; }
.ai-wf-node.is-type-http_tool::before { background: var(--ox-accent-foreground, var(--ox-accent)); }

.ai-wf-node.is-selected {
    border-color: var(--ox-accent);
    box-shadow: 0 0 0 2px var(--ox-focus-ring, color-mix(in oklab, var(--ox-accent) 35%, transparent));
}

.ai-wf-node.is-succeeded {
    border-color: var(--ox-status-on, #16a34a);
}

.ai-wf-node.is-failed {
    border-color: var(--ox-text-danger, #b91c1c);
}

.ai-wf-node-title {
    font-size: var(--ox-fs-body, 13px);
    font-weight: var(--ox-fw-semibold, 600);
    color: var(--ox-text-primary);
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-wf-node-type {
    margin-top: 4px;
    font-size: var(--ox-fs-secondary, 12px);
    color: var(--ox-muted);
}

.ai-wf-node-gear {
    position: absolute;
    top: 4px;
    right: 8px;
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    min-height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: var(--ox-radius, 4px);
    background: transparent;
    color: var(--ox-text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.45;
    z-index: 4;
    box-sizing: border-box;
}

.ai-wf-node:hover .ai-wf-node-gear,
.ai-wf-node.is-selected .ai-wf-node-gear,
.ai-wf-node-gear:focus-visible {
    opacity: 1;
}

.ai-wf-node-gear:hover {
    background: var(--ox-state-hover-bg);
    color: var(--ox-text-primary);
}

.ai-wf-node-gear .ph {
    font-size: 0.875rem;
    line-height: 1;
}

.ai-wf-port {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--ox-surface);
    border: 2px solid var(--ox-accent);
    box-sizing: border-box;
    cursor: crosshair;
    z-index: 3;
    touch-action: none;
}

.ai-wf-port:hover {
    background: var(--ox-accent);
}

.ai-wf-port-in {
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
}

.ai-wf-port-out {
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
}

.ai-wf-port-out.is-true {
    top: 22px;
    transform: none;
}

.ai-wf-port-out.is-false {
    top: auto;
    bottom: 16px;
    transform: none;
    border-color: var(--ox-muted);
}

.ai-wf-node.is-type-condition {
    min-height: 88px;
}

.ai-wf-hint {
    position: absolute;
    left: var(--ox-space, 0.5rem);
    bottom: var(--ox-space, 0.5rem);
    z-index: 4;
    padding: var(--ox-space-xs, 0.25rem) var(--ox-space, 0.5rem);
    border-radius: var(--ox-radius, 4px);
    background: color-mix(in oklab, var(--ox-surface) 88%, var(--ox-text-primary));
    border: 1px solid var(--ox-border);
    color: var(--ox-muted);
    font-size: var(--ox-fs-secondary, 12px);
    pointer-events: none;
}

.ai-wf-zoombar {
    position: absolute;
    right: var(--ox-space, 0.5rem);
    bottom: var(--ox-space, 0.5rem);
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--ox-border);
    border-radius: var(--ox-radius, 4px);
    background: color-mix(in oklab, var(--ox-surface) 92%, transparent);
    box-shadow: 0 1px 2px color-mix(in oklab, var(--ox-text-primary) 10%, transparent);
    user-select: none;
}

.ai-wf-zoombar-btn {
    width: var(--ox-icon-btn, 1.75rem);
    height: var(--ox-icon-btn, 1.75rem);
    min-width: var(--ox-icon-btn, 1.75rem);
    padding: 0;
    border: none;
    border-radius: var(--ox-radius, 4px);
    background: transparent;
    color: var(--ox-text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.ai-wf-zoombar-btn:hover {
    background: var(--ox-state-hover-bg);
    color: var(--ox-text-primary);
}

.ai-wf-zoombar-btn .ph {
    font-size: 0.875rem;
    line-height: 1;
}

.ai-wf-zoombar-pct {
    min-width: 2.75rem;
    height: var(--ox-icon-btn, 1.75rem);
    padding: 0 var(--ox-space, 0.5rem);
    border: none;
    border-radius: var(--ox-radius-sm, 3px);
    background: var(--ox-state-selected-chrome-bg, var(--ox-state-selected-bg));
    color: var(--ox-accent-foreground);
    font-size: var(--ox-fs-secondary);
    font-weight: var(--ox-fw-medium);
    line-height: 1;
    cursor: pointer;
}

.ai-wf-zoombar-pct:hover,
.ai-wf-zoombar-pct[aria-expanded="true"] {
    background: var(--ox-state-selected-chrome-bg-hover, var(--ox-state-selected-bg-hover));
    color: var(--ox-accent-foreground-strong);
}

.ai-wf-zoombar-sep {
    width: 1px;
    align-self: stretch;
    margin: 4px 2px;
    background: var(--ox-border);
}

.ai-wf-zoom-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 13.5rem;
    padding: var(--ox-space-xs, 0.25rem) 0;
    border: 1px solid var(--ox-border);
    border-radius: var(--ox-radius, 4px);
    background: var(--ox-surface);
    box-shadow: 0 1px 4px color-mix(in oklab, var(--ox-text-primary) 12%, transparent);
}

.ai-wf-zoom-menu[hidden] {
    display: none;
}

.ai-wf-zoom-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ox-space, 0.5rem);
    width: 100%;
    margin: 0;
    padding: 6px var(--ox-space, 0.5rem);
    border: none;
    background: transparent;
    color: var(--ox-text-body);
    font-size: var(--ox-fs-body);
    text-align: start;
    cursor: pointer;
    box-sizing: border-box;
}

.ai-wf-zoom-menu-item:hover {
    background: var(--ox-state-hover-bg);
}

.ai-wf-zoom-menu-item.is-active {
    background: var(--ox-state-selected-chrome-bg, var(--ox-state-selected-bg));
    color: var(--ox-accent-foreground);
}

.ai-wf-zoom-menu-sep {
    height: 1px;
    margin: var(--ox-space-xs, 0.25rem) 0;
    background: var(--ox-border);
}

.ai-wf-kbd {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ai-wf-kbd kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 4px;
    border: 1px solid var(--ox-border);
    border-radius: var(--ox-radius-sm, 3px);
    background: var(--ox-footer-bg, var(--ox-surface));
    color: var(--ox-text-secondary);
    font-size: var(--ox-fs-caption);
    font-family: inherit;
    font-weight: var(--ox-fw-regular);
    line-height: 1;
    box-sizing: border-box;
}
