/* ═══════════════════════════════════════════════════════════
   WORKFLOW — Poiiky Studio
   Multi-step AI generation pipelines
   Part 1: List View  |  Part 2: Canvas View  |  Part 3: Shared
   ═══════════════════════════════════════════════════════════ */

/* ╔═══════════════════════════════════════════════════════════╗
   ║  PART 1 — LIST VIEW (browse workflows)                   ║
   ╚═══════════════════════════════════════════════════════════╝ */

/* ── Header ──────────────────────────────────────────────── */
.wf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32px 0 20px;
}
.wf-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.wf-header-left > .i {
    color: var(--ac);
    filter: drop-shadow(0 0 10px rgba(212,255,74,.4));
    flex-shrink: 0;
}
.wf-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--tx);
    margin: 0;
    line-height: 1.2;
}
.wf-subtitle {
    font-size: 14px;
    color: var(--mut);
    margin: 4px 0 0;
}

/* ── Filter Pills ────────────────────────────────────────── */
.wf-filters {
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    padding: 12px 0;
}
.wf-filter-pills {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
}
.wf-filter-pills::-webkit-scrollbar { display: none; }

.wf-pill {
    flex-shrink: 0;
    padding: 8px 18px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--tx2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.wf-pill:hover {
    border-color: var(--ac);
    color: var(--ac);
    background: rgba(212,255,74,.06);
}
.wf-pill.active {
    background: rgba(212,255,74,.12);
    border-color: var(--ac);
    color: var(--ac);
    font-weight: 600;
}

/* ── Grid ────────────────────────────────────────────────── */
.wf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* ── Card ────────────────────────────────────────────────── */
.wf-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .3s cubic-bezier(.4,0,.2,1), box-shadow .3s, border-color .3s;
}
.wf-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(0,0,0,.35), 0 0 0 1px rgba(212,255,74,.2);
    border-color: rgba(212,255,74,.3);
}

.wf-card-cover {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--card2);
}
.wf-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s;
}
.wf-card:hover .wf-card-cover img {
    transform: scale(1.06);
}
.wf-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,.1) 0%, transparent 40%, transparent 60%, rgba(0,0,0,.6) 100%);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px;
    pointer-events: none;
}
.wf-card-category {
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.wf-card-featured {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(245,158,11,.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    animation: wf-star-pulse 2s ease-in-out infinite;
}
@keyframes wf-star-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(245,158,11,0); }
    50% { box-shadow: 0 0 12px rgba(245,158,11,.4); }
}

.wf-card-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--card2), var(--card));
    display: flex;
    align-items: center;
    justify-content: center;
}
.wf-card-placeholder svg {
    width: 48px;
    height: 48px;
    color: var(--mut);
    opacity: .4;
}

.wf-card-info {
    padding: 16px 18px 18px;
}
.wf-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--tx);
    margin: 0 0 6px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.wf-card-desc {
    font-size: 13px;
    color: var(--mut);
    margin: 0 0 14px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.wf-card-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.wf-card-stat {
    font-size: 12px;
    color: var(--tx2);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--card2);
    border: 1px solid var(--line);
}
.wf-card-stat .emoji { font-size: 11px; }
.wf-card-btn {
    width: 100%;
    padding: 10px 16px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--ac), var(--ac2, #b8ff6e));
    color: #09090b;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .2s;
    box-shadow: 0 2px 10px rgba(212,255,74,.2);
}
.wf-card-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(212,255,74,.35);
}
.wf-card-btn:active { transform: translateY(0); }

/* ╔═══════════════════════════════════════════════════════════╗
   ║  PART 2 — CANVAS VIEW (n8n-style node editor)            ║
   ╚═══════════════════════════════════════════════════════════╝ */

/* ── Main Container ──────────────────────────────────────── */
.wfc {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: var(--bg);
}

/* ── Top Bar ─────────────────────────────────────────────── */
.wfc-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(9,9,11,.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    z-index: 100;
    gap: 16px;
}
.wfc-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--tx2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
    flex-shrink: 0;
    white-space: nowrap;
}
.wfc-back:hover {
    border-color: var(--ac);
    color: var(--ac);
    background: rgba(212,255,74,.06);
}

.wfc-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--tx);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    text-align: center;
}

.wfc-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.wfc-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--tx2);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.wfc-btn:hover { background: var(--card2); color: var(--tx); border-color: var(--ac); }
.wfc-btn:active { background: rgba(212,255,74,.1); }

.wfc-zoom {
    padding: 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--mut);
    min-width: 42px;
    text-align: center;
    user-select: none;
}

.wfc-run-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, var(--ac), var(--ac2, #b8ff6e));
    color: #09090b;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .2s;
    box-shadow: 0 2px 10px rgba(212,255,74,.25);
    letter-spacing: .3px;
}
.wfc-run-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(212,255,74,.4);
}
.wfc-run-btn:active { transform: translateY(0); }
.wfc-run-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Canvas Viewport ─────────────────────────────────────── */
.wfc-viewport {
    position: absolute;
    top: 56px;
    left: 0; right: 0; bottom: 0;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}
.wfc-viewport.grabbing { cursor: grabbing; }

.wfc-bg {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,.06) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
}

/* ── Nodes & Connections Layers ──────────────────────────── */
.wfc-connections {
    position: absolute;
    top: 0; left: 0;
    width: 1px; height: 1px;
    overflow: visible;
    pointer-events: none;
    z-index: 1;
    transform-origin: 0 0;
    will-change: transform;
}

.wfc-nodes {
    position: absolute;
    top: 0; left: 0;
    transform-origin: 0 0;
    will-change: transform;
    z-index: 2;
}

/* ── Connection Paths (SVG) ──────────────────────────────── */
.wfc-conn-shadow {
    fill: none;
    stroke: rgba(0,0,0,.3);
    stroke-width: 6;
    pointer-events: none;
    filter: blur(3px);
}
.wfc-conn {
    fill: none;
    stroke: var(--line);
    stroke-width: 2;
    pointer-events: stroke;
    transition: stroke .2s, stroke-width .15s;
}
.wfc-conn:hover {
    stroke: var(--ac);
    stroke-width: 3;
}
.wfc-conn.active {
    stroke: var(--ac);
    stroke-width: 2.5;
    stroke-dasharray: 8 4;
    animation: wfc-flow 1s linear infinite;
}
.wfc-conn.completed { stroke: var(--success); stroke-width: 2; }
.wfc-conn.failed { stroke: var(--danger); stroke-width: 2; stroke-dasharray: 4 4; }
@keyframes wfc-flow { to { stroke-dashoffset: -12; } }

/* ── Node Cards ──────────────────────────────────────────── */
.wfc-node {
    position: absolute;
    width: 260px;
    background: var(--card);
    border: 2px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,.3);
    transition: box-shadow .25s, border-color .25s, transform .15s;
    user-select: none;
    z-index: 3;
    cursor: pointer;
    overflow: visible;
}
.wfc-node:hover {
    border-color: rgba(255,255,255,.2);
    box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.06);
    z-index: 4;
    transform: translateY(-1px);
}

/* Type-specific left-border accent */
.wfc-node[data-type="prompt"]         { border-left: 3px solid #a78bfa; }
.wfc-node[data-type="upload_image"]   { border-left: 3px solid #22d3ee; }
.wfc-node[data-type="gemini_prompt"]  { border-left: 3px solid #f472b6; }
.wfc-node[data-type="generate_image"] { border-left: 3px solid #34d399; }
.wfc-node[data-type="generate_video"] { border-left: 3px solid #fb923c; }

/* Node header */
.wfc-node-header {
    padding: 10px 14px;
    border-radius: 10px 10px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #fff;
    min-height: 40px;
    box-sizing: border-box;
}
.wfc-node-icon { flex-shrink: 0; font-size: 14px; }
.wfc-node-label {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Node body */
.wfc-node-body {
    padding: 0;
    border-top: 1px solid rgba(255,255,255,.04);
    min-height: 36px;
    transition: background .3s, border-color .3s;
}

/* ── Inline Widgets (ComfyUI style) ──────────────────────── */
.wfc-widget { margin: 0; }

/* Upload widget */
.wfc-widget-upload {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 0 0 10px 10px;
    transition: background .2s;
}
.wfc-widget-upload:hover { background: rgba(255,255,255,.03); }
.wfc-widget-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.wfc-widget-upload-inner {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 50px;
}
.wfc-widget-upload-placeholder {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--mut);
    font-size: 11px;
}
.wfc-widget-upload-placeholder svg { flex-shrink: 0; }
.wfc-widget-upload-label { font-size: 10px; color: var(--mut); }
.wfc-widget-upload-ok { color: var(--success) !important; font-weight: 600; }
.wfc-widget-thumb {
    width: 100%;
    max-height: 100px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

/* Text widget */
.wfc-widget-text { padding: 6px 8px 8px; }
.wfc-widget-textarea {
    width: 100%;
    min-height: 44px;
    max-height: 80px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,.08);
    background: rgba(0,0,0,.2);
    color: var(--tx);
    font-size: 11px;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    transition: border-color .2s;
    box-sizing: border-box;
}
.wfc-widget-textarea:focus {
    outline: none;
    border-color: var(--ac);
}
.wfc-widget-textarea::placeholder { color: rgba(255,255,255,.25); }

/* Config rows widget (generate, gemini) */
.wfc-widget-rows { padding: 6px 0; }
.wfc-widget-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 12px;
    font-size: 11px;
    min-height: 22px;
    transition: background .15s;
}
.wfc-widget-row:hover { background: rgba(255,255,255,.03); }
.wfc-wr-k {
    color: var(--mut);
    font-weight: 500;
    flex-shrink: 0;
    margin-right: 8px;
}
.wfc-wr-v {
    color: var(--tx);
    font-weight: 600;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    padding: 1px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,.04);
}
.wfc-widget-row--text .wfc-wr-v {
    max-width: 140px;
}

/* Node run status (via body class) */
.wfc-node-body.wfc-node--running {
    background: rgba(245,158,11,.08);
    border-color: rgba(245,158,11,.2);
    animation: wfc-node-pulse 1.5s ease-in-out infinite;
}
.wfc-node-body.wfc-node--done {
    background: rgba(34,197,94,.06);
    border-color: rgba(34,197,94,.15);
}
.wfc-node-body.wfc-node--failed {
    background: rgba(239,68,68,.06);
    border-color: rgba(239,68,68,.15);
}
@keyframes wfc-node-pulse {
    0%, 100% { background: rgba(245,158,11,.06); }
    50% { background: rgba(245,158,11,.14); }
}

/* ── Ports (new: dot + label layout) ─────────────────────── */
.wfc-node-ports-in,
.wfc-node-ports-out {
    position: absolute;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 44px; /* below header */
}
.wfc-node-ports-in  { left: -6px; }
.wfc-node-ports-out { right: -6px; }

.wfc-port {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: default;
    position: relative;
    z-index: 5;
    height: 20px;
}
.wfc-port.in { flex-direction: row; }
.wfc-port.out { flex-direction: row; justify-content: flex-end; }

.wfc-port-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2.5px solid var(--card);
    flex-shrink: 0;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.wfc-port:hover .wfc-port-dot {
    transform: scale(1.35);
    box-shadow: 0 0 8px rgba(255,255,255,.25);
}

.wfc-port-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--mut);
    white-space: nowrap;
    letter-spacing: .3px;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}
.wfc-node:hover .wfc-port-label { opacity: 1; }

/* ── Frame Nodes (grouping boxes) ────────────────────────── */
.wfc-frame {
    position: absolute;
    border: 2px dashed rgba(255,255,255,.07);
    border-radius: 16px;
    background: rgba(255,255,255,.015);
    z-index: 0;
    pointer-events: none;
}
.wfc-frame-label {
    position: absolute;
    top: -14px;
    left: 16px;
    padding: 3px 12px;
    background: var(--card2);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--mut);
    white-space: nowrap;
    letter-spacing: .3px;
    text-transform: uppercase;
}

/* ── Minimap ─────────────────────────────────────────────── */
.wfc-minimap {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 140px;
    background: rgba(23,23,28,.92);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0,0,0,.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.wfc-minimap canvas {
    width: 100%;
    height: 100%;
}
.wfc-minimap-vp {
    position: absolute;
    border: 1.5px solid var(--ac);
    border-radius: 2px;
    background: rgba(212,255,74,.06);
    pointer-events: none;
}

/* ── Info Panel ──────────────────────────────────────────── */
.wfc-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    z-index: 60;
    padding: 0;
}
.wfc-info-close {
    position: absolute;
    top: 10px; right: 10px;
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--card2);
    color: var(--tx);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.wfc-info-close:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.wfc-info-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 10px;
}
.wfc-info-icon { font-size: 20px; flex-shrink: 0; }
.wfc-info-type {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    padding: 2px 8px; border-radius: 4px; background: var(--card2); color: var(--mut);
}
.wfc-info-name {
    font-size: 14px; font-weight: 700; color: var(--tx); margin-top: 2px;
}
.wfc-info-id {
    font-size: 11px; color: var(--mut); font-family: monospace;
    padding: 8px 18px 14px;
}

/* ── Info Panel: Upload Dropzone ─────────────────────────── */
.wfc-info-upload {
    position: relative;
    border: 2px dashed var(--line);
    border-radius: 10px;
    cursor: pointer;
    transition: all .2s;
    background: var(--card2);
    overflow: hidden;
    margin-top: 6px;
}
.wfc-info-upload:hover {
    border-color: var(--ac);
    background: rgba(212,255,74,.04);
}
.wfc-info-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.wfc-info-upload-inner {
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}
.wfc-info-upload-preview {
    max-width: 100%;
    max-height: 120px;
    border-radius: 8px;
    object-fit: cover;
}
.wfc-info-upload-icon { color: var(--mut); }
.wfc-info-upload-text { font-size: 12px; color: var(--mut); }
.wfc-info-upload-ok { font-size: 12px; color: var(--success); font-weight: 600; }
.wfc-info-upload-hint { font-size: 10px; color: var(--mut); }

/* ── Info Panel: Textarea ────────────────────────────────── */
.wfc-info-textarea {
    width: 100%;
    min-height: 70px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--line);
    background: var(--card2);
    color: var(--tx);
    font-size: 12px;
    font-family: inherit;
    line-height: 1.45;
    resize: vertical;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
    margin-top: 6px;
}
.wfc-info-textarea:focus {
    outline: none;
    border-color: var(--ac);
    box-shadow: 0 0 0 2px rgba(212,255,74,.1);
}
.wfc-info-textarea::placeholder { color: var(--mut); }

/* ── Info Panel: CTA Button ──────────────────────────────── */
.wfc-info-cta {
    padding: 12px 18px 4px;
}
.wfc-info-run-btn {
    width: 100%;
    padding: 10px 16px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--ac), var(--ac2, #b8ff6e));
    color: #09090b;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .2s;
    box-shadow: 0 2px 10px rgba(212,255,74,.2);
}
.wfc-info-run-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(212,255,74,.35);
}
.wfc-info-run-btn:active { transform: translateY(0); }

/* Node has-data indicator (green glow on border) */
.wfc-node--has-data {
    border-color: rgba(34,197,94,.4) !important;
    box-shadow: 0 4px 16px rgba(0,0,0,.3), 0 0 0 1px rgba(34,197,94,.2) !important;
}

/* Light mode overrides */
[data-theme="light"] .wfc-info-upload { background: #f5f5f5; border-color: #e0e0e0; }
[data-theme="light"] .wfc-info-upload:hover { background: rgba(100,180,30,.04); border-color: rgba(100,180,30,.4); }
[data-theme="light"] .wfc-info-textarea { background: #f8f8f8; border-color: #e0e0e0; color: #111; }
[data-theme="light"] .wfc-info-run-btn { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; }
.wfc-info-section {
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255,255,255,.04);
}
.wfc-info-section:last-child { border-bottom: none; }
.wfc-info-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    color: var(--mut); margin-bottom: 6px;
}
.wfc-info-text {
    font-size: 12px; color: var(--tx2); line-height: 1.5;
    max-height: 100px; overflow-y: auto;
    white-space: pre-wrap; word-break: break-word;
}
.wfc-info-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; font-size: 12px; color: var(--tx2);
}
.wfc-info-ports {
    display: flex; flex-direction: column; gap: 6px;
    padding: 0 18px 12px;
}
.wfc-info-port {
    display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--tx2);
}
.wfc-info-port-dot {
    width: 10px; height: 10px; border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 4px rgba(0,0,0,.3);
}

/* ╔═══════════════════════════════════════════════════════════╗
   ║  PART 3 — SHARED (Modals, Loading, etc.)                 ║
   ╚═══════════════════════════════════════════════════════════╝ */

/* ── Run Modal ───────────────────────────────────────────── */
.wf-modal, .wf-progress-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .25s;
    pointer-events: none;
}
.wf-modal.open, .wf-progress-modal.open {
    opacity: 1;
    pointer-events: auto;
}
.wf-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.wf-modal-content {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    width: 92vw;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,.5);
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
    transform: translateY(20px) scale(.97);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.wf-modal.open .wf-modal-content,
.wf-progress-modal.open .wf-progress-content {
    transform: translateY(0) scale(1);
}
.wf-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--card2);
    color: var(--tx);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
}
.wf-modal-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.wf-modal-body {
    padding: 28px 24px 24px;
}

/* Modal inner sections */
.wf-modal-info { margin-bottom: 24px; }
.wf-modal-name {
    font-size: 22px;
    font-weight: 800;
    color: var(--tx);
    margin: 0 0 8px;
    padding-right: 36px;
}
.wf-modal-desc {
    font-size: 14px;
    color: var(--mut);
    line-height: 1.5;
    margin: 0 0 16px;
}
.wf-modal-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.wf-modal-stat {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 8px;
    background: var(--card2);
    border: 1px solid var(--line);
    color: var(--tx2);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Upload inputs */
.wf-inputs-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--tx);
    margin: 0 0 14px;
}
.wf-filled-hint {
    font-size: 12px;
    color: var(--success);
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(34,197,94,.08);
    border: 1px solid rgba(34,197,94,.15);
    margin-bottom: 14px;
}
.wf-input-item {
    margin-bottom: 16px;
}
.wf-input-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--tx2);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.wf-input-label .req {
    color: var(--danger);
    font-weight: 700;
}

/* Text input for prompt nodes */
.wf-textarea {
    width: 100%;
    min-height: 90px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 2px solid var(--line);
    background: var(--card2);
    color: var(--tx);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}
.wf-textarea:focus {
    outline: none;
    border-color: var(--ac);
    box-shadow: 0 0 0 3px rgba(212,255,74,.1);
}
.wf-textarea::placeholder { color: var(--mut); }

/* Dropzone */
.wf-dropzone {
    border: 2px dashed var(--line);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--card2);
    position: relative;
    overflow: hidden;
}
.wf-dropzone:hover {
    border-color: var(--ac);
    background: rgba(212,255,74,.04);
}
.wf-dropzone.uploading {
    border-color: var(--gold);
    border-style: solid;
    background: rgba(245,158,11,.04);
}
.wf-dropzone.has-file {
    border-color: var(--success);
    border-style: solid;
    background: rgba(34,197,94,.06);
}
.wf-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.wf-dropzone-inner {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.wf-dropzone-icon {
    color: var(--mut);
}
.wf-dropzone-icon-ok {
    font-size: 32px;
    margin-bottom: 4px;
}
.wf-dropzone-text {
    font-size: 13px;
    color: var(--mut);
}
.wf-dropzone-text strong {
    color: var(--ac);
}
.wf-dropzone-preview {
    max-width: 120px;
    max-height: 80px;
    border-radius: 8px;
    object-fit: cover;
}
.wf-dropzone-filename {
    font-size: 12px;
    font-weight: 600;
}
.wf-dropzone-success { color: var(--success); }
.wf-dropzone-error { color: var(--danger); }
.wf-dropzone-change {
    font-size: 11px;
    color: var(--mut);
    margin-top: 2px;
}

/* Cost row */
.wf-cost-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--card2);
    border: 1px solid var(--line);
    margin-bottom: 18px;
}
.wf-cost-label {
    font-size: 13px;
    color: var(--mut);
}
.wf-cost-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--ac);
}

/* Start button */
.wf-start-btn {
    width: 100%;
    padding: 15px 24px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--ac), var(--ac2, #b8ff6e));
    color: #09090b;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all .2s;
    box-shadow: 0 4px 16px rgba(212,255,74,.25);
    letter-spacing: .3px;
}
.wf-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(212,255,74,.35);
}
.wf-start-btn:active { transform: translateY(0); }
.wf-start-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.wf-start-btn .i { color: #09090b; }
.wf-btn-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(9,9,11,.3);
    border-top-color: #09090b;
    border-radius: 50%;
    animation: wf-spin .7s linear infinite;
}
@keyframes wf-spin { to { transform: rotate(360deg); } }

.wf-modal-hint {
    font-size: 12px;
    color: var(--mut);
    text-align: center;
    margin: 12px 0 0;
}

/* ── Progress Modal ──────────────────────────────────────── */
.wf-progress-content {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    width: 92vw;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,.5);
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
    padding: 28px 24px 24px;
    transform: translateY(20px) scale(.97);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}

.wf-progress-header {
    text-align: center;
    margin-bottom: 24px;
}
.wf-progress-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--tx);
    margin: 0 0 16px;
}
.wf-progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 10px;
    background: var(--card2);
    border: 1px solid var(--line);
    overflow: hidden;
    margin-bottom: 10px;
}
.wf-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--ac), var(--ac2, #b8ff6e));
    transition: width .5s ease;
    box-shadow: 0 0 10px rgba(212,255,74,.3);
}
.wf-progress-text {
    font-size: 13px;
    color: var(--mut);
    margin: 0;
}

/* Step list */
.wf-progress-steps {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
    margin-bottom: 20px;
}
.wf-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 4px;
    transition: background .2s;
}
.wf-step:hover { background: rgba(255,255,255,.03); }
.wf-step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}
.wf-step-icon.pending {
    background: var(--card2);
    border: 1px solid var(--line);
    color: var(--mut);
}
.wf-step-icon.running {
    background: rgba(245,158,11,.15);
    border: 1px solid rgba(245,158,11,.3);
    color: var(--gold);
    animation: wf-spin .8s linear infinite;
}
.wf-step-icon.done {
    background: rgba(34,197,94,.15);
    border: 1px solid rgba(34,197,94,.3);
    color: var(--success);
}
.wf-step-icon.failed {
    background: rgba(239,68,68,.15);
    border: 1px solid rgba(239,68,68,.3);
    color: var(--danger);
}
.wf-step-info { flex: 1; min-width: 0; }
.wf-step-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--tx);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wf-step-type {
    font-size: 11px;
    color: var(--mut);
}
.wf-step-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}
.wf-step-status.running { background: rgba(245,158,11,.12); color: var(--gold); }
.wf-step-status.done    { background: rgba(34,197,94,.12); color: var(--success); }
.wf-step-status.failed  { background: rgba(239,68,68,.12); color: var(--danger); }
.wf-step-status.waiting { background: rgba(99,102,241,.12); color: #818cf8; }

/* Output gallery */
.wf-progress-outputs {
    border-top: 1px solid var(--line);
    padding-top: 20px;
}
.wf-outputs-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--tx);
    margin: 0 0 14px;
}
.wf-outputs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.wf-output-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: var(--card2);
    border: 1px solid var(--line);
    aspect-ratio: 9 / 16;
}
.wf-output-item img,
.wf-output-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.wf-output-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}
.wf-output-dl {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}
.wf-output-dl:hover { background: var(--ac); color: #09090b; }
.wf-output-type {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ── Error state ─────────────────────────────────────────── */
.wf-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--danger);
    font-size: 14px;
}

/* ── Loading ─────────────────────────────────────────────── */
.wf-loading {
    display: flex;
    justify-content: center;
    padding: 48px 0;
}
.wf-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--line);
    border-top-color: var(--ac);
    border-radius: 50%;
    animation: wf-spin .7s linear infinite;
}

/* ── Empty state ─────────────────────────────────────────── */
.wf-empty {
    text-align: center;
    padding: 64px 20px;
    color: var(--mut);
}
.wf-empty svg {
    color: var(--line);
    margin-bottom: 16px;
}
.wf-empty p { font-size: 15px; margin: 0; }

/* ── Pagination ──────────────────────────────────────────── */
.wf-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 32px 0 24px;
}

/* ╔═══════════════════════════════════════════════════════════╗
   ║  LIGHT MODE                                               ║
   ╚═══════════════════════════════════════════════════════════╝ */
[data-theme="light"] .wf-filters { background: var(--bg); }
[data-theme="light"] .wf-card {
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
[data-theme="light"] .wf-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,.1), 0 0 0 1px rgba(100,180,30,.2);
    border-color: rgba(100,180,30,.3);
}
[data-theme="light"] .wf-modal-content,
[data-theme="light"] .wf-progress-content {
    box-shadow: 0 24px 64px rgba(0,0,0,.2);
}
[data-theme="light"] .wf-card-btn,
[data-theme="light"] .wf-start-btn,
[data-theme="light"] .wf-run-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    box-shadow: 0 4px 16px rgba(34,197,94,.2);
}
[data-theme="light"] .wf-card-btn:hover,
[data-theme="light"] .wf-start-btn:hover,
[data-theme="light"] .wf-run-btn:hover {
    box-shadow: 0 6px 24px rgba(34,197,94,.3);
}
[data-theme="light"] .wf-card-btn .i,
[data-theme="light"] .wf-start-btn .i,
[data-theme="light"] .wf-run-btn .i { color: #fff; }
[data-theme="light"] .wf-cost-value { color: #16a34a; }
[data-theme="light"] .wf-progress-fill {
    background: linear-gradient(90deg, #22c55e, #16a34a);
    box-shadow: 0 0 10px rgba(34,197,94,.3);
}

/* Canvas light mode */
[data-theme="light"] .wfc {
    background-image: radial-gradient(circle, rgba(0,0,0,.08) 1px, transparent 1px);
}
[data-theme="light"] .wfc-topbar {
    background: rgba(255,255,255,.92);
}
[data-theme="light"] .wfc-node {
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    border-color: rgba(0,0,0,.1);
}
[data-theme="light"] .wfc-node:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    border-color: rgba(0,0,0,.18);
}
[data-theme="light"] .wfc-node-body { border-top-color: rgba(0,0,0,.06); }
[data-theme="light"] .wfc-port-dot { border-color: var(--card); }
[data-theme="light"] .wfc-widget-textarea { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.1); color: #111; }
[data-theme="light"] .wfc-widget-textarea::placeholder { color: rgba(0,0,0,.3); }
[data-theme="light"] .wfc-wr-v { background: rgba(0,0,0,.04); }
[data-theme="light"] .wfc-widget-upload:hover { background: rgba(0,0,0,.02); }
[data-theme="light"] .wfc-frame {
    border-color: rgba(0,0,0,.08);
    background: rgba(0,0,0,.015);
}
[data-theme="light"] .wfc-minimap {
    background: rgba(255,255,255,.92);
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
[data-theme="light"] .wfc-info {
    background: rgba(255,255,255,.95);
}
[data-theme="light"] .wf-textarea {
    background: #f8f8f8;
    border-color: #e0e0e0;
    color: #111;
}

/* ╔═══════════════════════════════════════════════════════════╗
   ║  RESPONSIVE                                               ║
   ╚═══════════════════════════════════════════════════════════╝ */
@media (max-width: 768px) {
    .wf-header { padding: 20px 0 14px; }
    .wf-title { font-size: 20px; }
    .wf-subtitle { font-size: 12px; }
    .wf-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 14px;
    }
    .wf-modal-content, .wf-progress-content {
        width: 96vw;
        max-height: 95vh;
        border-radius: 16px;
    }
    .wf-modal-body { padding: 20px 18px 24px; }
    .wf-modal-name { font-size: 18px; }
    .wf-start-btn { font-size: 15px; padding: 13px 20px; }
    .wf-outputs-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }

    /* Canvas responsive */
    .wfc-topbar {
        height: 48px;
        padding: 0 12px;
        gap: 8px;
    }
    .wfc-viewport { top: 48px; }
    .wfc-back { padding: 5px 10px; font-size: 12px; }
    .wfc-title { font-size: 13px; }
    .wfc-controls { display: none; }
    .wfc-run-btn { padding: 6px 14px; font-size: 12px; }
    .wfc-minimap { display: none; }
    .wfc-info { bottom: 12px; left: 12px; max-width: calc(100vw - 24px); }

    .wfc-node { width: 220px; }
    .wfc-node-header { padding: 8px 10px; font-size: 10px; min-height: 36px; }
    .wfc-node-body { min-height: 28px; }
    .wfc-widget-textarea { font-size: 10px; min-height: 36px; }
    .wfc-widget-row { font-size: 10px; padding: 2px 10px; }
    .wfc-widget-thumb { max-height: 70px; }
    .wfc-node-ports-in,
    .wfc-node-ports-out { padding-top: 38px; }
    .wfc-port-label { display: none; }
}
@media (max-width: 480px) {
    .wf-grid { grid-template-columns: 1fr; }
    .wf-pill { padding: 6px 14px; font-size: 12px; }
    .wf-card-stats { gap: 6px; }
    .wf-card-stat { font-size: 11px; padding: 2px 6px; }
}
