/* ==================== 在线流程图 ==================== */
.flow-card { padding: 16px; }

.flow-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.flow-head h1, .flow-head h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 2px; }
.flow-head-text { max-width: 660px; }
.flow-head-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 工具栏 */
.flow-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    margin-bottom: 10px;
    background: #fbfbfc;
    border: 1px solid var(--border);
    border-radius: 12px;
}

/* 主体三栏 */
.flow-main {
    display: grid;
    grid-template-columns: 208px minmax(0, 1fr) 252px;
    gap: 12px;
    height: min(70vh, 680px);
}

/* 左侧素材库 */
.flow-lib {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fbfbfc;
    border: 1px solid var(--border);
    border-radius: 12px;
}
.lib-search { padding: 8px; border-bottom: 1px solid var(--border); }
.lib-search input {
    width: 100%;
    padding: 6px 10px;
    font-size: .8rem;
    line-height: 1.5;
    color: var(--field-text);
    background-color: var(--field-bg);
    border: 1px solid var(--field-border);
    border-radius: var(--field-radius);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.lib-search input::placeholder { color: var(--field-placeholder); }
.lib-search input:hover { border-color: var(--field-border-hover); }
.lib-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--field-focus-ring);
}
.lib-body { flex: 1; min-height: 0; overflow: auto; padding: 6px 8px 10px; }
.lib-cat { margin-bottom: 2px; }
.lib-cat-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 2px;
    border: 0;
    background: none;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--text-dim);
    cursor: pointer;
}
.lib-cat-head:hover { color: var(--accent); }
.lib-cat-head .lib-caret { font-size: .6rem; opacity: .7; transition: transform .15s ease; }
.lib-cat.collapsed .lib-caret { transform: rotate(-90deg); }
.lib-cat.collapsed .lib-grid { display: none; }
.lib-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 2px 0 6px; }
.lib-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px 5px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: grab;
    font-size: .62rem;
    line-height: 1.2;
    color: var(--text-dim);
    text-align: center;
    transition: border-color .15s ease, color .15s ease, transform .12s ease;
}
.lib-item:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.lib-item:active { cursor: grabbing; }
.lib-item svg { width: 28px; height: 20px; display: block; }
.lib-item svg path { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.lib-empty { padding: 14px 4px; font-size: .76rem; color: var(--text-dim); text-align: center; }

.lib-tpl { border-top: 1px solid var(--border); padding: 8px; }
.lib-tpl h4 { margin: 0 0 6px; font-size: .72rem; font-weight: 700; color: var(--text-dim); letter-spacing: .04em; }
.lib-tpl-btns { display: flex; flex-direction: column; gap: 4px; }

/* 画布 */
.flow-stage {
    position: relative;
    overflow: hidden;
    background: #eef0f3;
    border: 1px solid var(--border);
    border-radius: 12px;
    touch-action: none;
}
.flow-stage.dragover { box-shadow: inset 0 0 0 2px var(--accent); background: #ffece5; }
.flow-paper {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .16);
    will-change: width, height;
}
.flow-paper.is-transparent {
    background-image:
        linear-gradient(45deg, #e4e7ea 25%, transparent 25%),
        linear-gradient(-45deg, #e4e7ea 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e4e7ea 75%),
        linear-gradient(-45deg, transparent 75%, #e4e7ea 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
#flowSvg {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
#flowSvg .fnode { cursor: move; }
#flowSvg .fnode.is-locked { cursor: default; }
#flowSvg .fedge-hit { cursor: pointer; }
#flowSvg [data-handle] { cursor: nwse-resize; }
#flowSvg [data-handle="n"], #flowSvg [data-handle="s"] { cursor: ns-resize; }
#flowSvg [data-handle="e"], #flowSvg [data-handle="w"] { cursor: ew-resize; }
#flowSvg [data-handle="ne"], #flowSvg [data-handle="sw"] { cursor: nesw-resize; }
#flowSvg [data-port] { cursor: crosshair; }

/* 画布右下角缩放条 */
.flow-zoombar {
    position: absolute;
    left: 10px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: rgba(255, 255, 255, .94);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .1);
}
.flow-zoombar .zb-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--text-dim);
    font-size: .95rem;
    line-height: 1;
    cursor: pointer;
}
.flow-zoombar .zb-btn:hover { background: #edeff2; color: var(--text); }
.flow-zoombar .zb-val {
    min-width: 42px;
    text-align: center;
    font-size: .74rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* 浮动文字输入框 */
.flow-text-input {
    position: absolute;
    z-index: 6;
    margin: 0;
    padding: 2px 4px;
    border: 1px solid var(--accent);
    border-radius: 3px;
    background: #fff;
    color: var(--text);
    outline: none;
    resize: none;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .16);
    line-height: 1.35;
    text-align: center;
}

/* 右侧面板 */
.flow-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: auto; }
.flow-side .side-card { padding: 10px 11px; }
.prop-empty { font-size: .76rem; color: var(--text-dim); line-height: 1.6; }
.prop-text {
    width: 100%;
    min-height: 54px;
    padding: 4px 6px;
    font-size: .8rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    resize: vertical;
    outline: none;
}
.prop-text:focus { border-color: var(--accent); }
.prop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.prop-grid .btn { font-size: .74rem; padding: .2rem .3rem; }
.prop-multi { font-size: .74rem; color: var(--accent); margin-top: 6px; }
.prop-color-row { display: flex; align-items: center; gap: 6px; }
.prop-swatch {
    width: 30px;
    height: 24px;
    padding: 2px;
    border: 1px solid var(--field-border);
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
}
.flow-foot {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
    font-size: .74rem;
    color: var(--text-dim);
}

/* 全屏 */
.flow-shell:fullscreen {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: #fff;
}
.flow-shell:fullscreen .flow-main { flex: 1; height: auto; min-height: 0; }

@media (max-width: 1000px) {
    .flow-main { grid-template-columns: 160px minmax(0, 1fr); height: auto; }
    .flow-side { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; overflow: visible; }
    .flow-side .side-card { flex: 1 1 200px; }
    .flow-stage { height: 56vh; }
}
@media (max-width: 720px) {
    .flow-main { grid-template-columns: 1fr; }
    .flow-lib { max-height: 190px; }
    .flow-stage { height: 48vh; }
}
