/* ============================================================
   Idea Canvas - node canvas page (engine + page chrome)
   Dark premium theme, purple-cyan gradients, glassmorphism.
   Depends on app.css variables (var(--bg-...), var(--grad) ...).
   ============================================================ */

/* Full-bleed canvas page: drop the default content padding */
body[data-page="canvas"] .content { padding: 0; }

/* ---------------- Page shell ---------------- */
.cv-shell {
    display: flex; flex-direction: column;
    height: calc(100vh - var(--topbar-h));
    min-height: 540px;
}
.cv-main { flex: 1; display: flex; min-height: 0; position: relative; }
.cv-canvas-wrap { flex: 1; position: relative; min-width: 0; }

/* ---------------- Toolbar ---------------- */
.cv-toolbar {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(13, 13, 20, 0.88);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    flex: none; z-index: 8;
}
.cv-back {
    display: inline-flex; align-items: center; gap: 7px;
    color: var(--text-2); font-size: 13px; font-weight: 600;
    transition: var(--transition);
}
.cv-back:hover { color: var(--text-1); transform: translateX(-2px); }
.cv-title { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; white-space: nowrap; }
.cv-title i { color: #A78BFA; font-size: 18px; }
.cv-title b {
    background: var(--grad-text);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}
.cv-tools { display: flex; gap: 8px; align-items: center; }
.cv-tool-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 13px; border-radius: 11px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-1); font-size: 12.5px; font-weight: 600;
    transition: var(--transition); white-space: nowrap;
}
.cv-tool-btn i { font-size: 14px; }
.cv-tool-btn:hover {
    background: rgba(139, 92, 246, 0.14);
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: var(--glow-sm);
    transform: translateY(-1px); color: #fff;
}
.cv-tool-btn.tb-text:hover { border-color: rgba(139, 92, 246, 0.6); }
.cv-tool-btn.tb-image:hover { border-color: rgba(6, 182, 212, 0.55); }
.cv-tool-btn.tb-video:hover { border-color: rgba(245, 158, 11, 0.55); background: rgba(245, 158, 11, 0.1); }
.cv-tool-btn.tb-clear:hover { border-color: rgba(239, 68, 68, 0.55); background: rgba(239, 68, 68, 0.1); color: #F87171; }

/* the three "add" buttons carry a colour-coded outline + tint so they
   read as primary actions instead of blending into the toolbar */
.cv-tool-btn.tb-text,
.cv-tool-btn.tb-image,
.cv-tool-btn.tb-video {
    border-width: 1.5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.cv-tool-btn.tb-text {
    border-color: rgba(139, 92, 246, 0.62);
    background: rgba(139, 92, 246, 0.14);
}
.cv-tool-btn.tb-text i { color: #A78BFA; }
.cv-tool-btn.tb-image {
    border-color: rgba(6, 182, 212, 0.6);
    background: rgba(6, 182, 212, 0.13);
}
.cv-tool-btn.tb-image i { color: #22D3EE; }
.cv-tool-btn.tb-video {
    border-color: rgba(245, 158, 11, 0.6);
    background: rgba(245, 158, 11, 0.13);
}
.cv-tool-btn.tb-video i { color: #FBBF24; }
.cv-tool-btn.tb-text:hover { background: rgba(139, 92, 246, 0.24); }
.cv-tool-btn.tb-image:hover { background: rgba(6, 182, 212, 0.22); }
.cv-tool-btn.tb-video:hover { background: rgba(245, 158, 11, 0.22); }

.cv-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.cv-zoom {
    display: flex; align-items: center; gap: 2px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px; padding: 3px;
}
.cv-zbtn {
    min-width: 28px; height: 26px; padding: 0 8px; border-radius: 7px;
    color: var(--text-2); display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; transition: var(--transition);
}
.cv-zbtn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.cv-zval { min-width: 46px; text-align: center; font-size: 11.5px; color: var(--text-2); font-weight: 600; }
.cv-save {
    font-size: 11.5px; color: var(--text-3); font-weight: 600;
    display: inline-flex; align-items: center; gap: 5px; min-width: 62px; white-space: nowrap;
}
.cv-save.saving { color: #FBBF24; }
.cv-save.saved { color: #34D399; }

/* ---------------- Canvas viewport ---------------- */
.nb-viewport {
    position: absolute; inset: 0; overflow: hidden;
    cursor: grab; touch-action: none;
    background-color: var(--bg-base);
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.08) 1px, transparent 1.4px);
    background-repeat: repeat;
}
.nb-viewport.panning { cursor: grabbing; }
.nb-world {
    position: absolute; top: 0; left: 0;
    transform-origin: 0 0; will-change: transform;
}

/* ---------------- Edge layer ---------------- */
.nb-svg {
    position: absolute; left: 0; top: 0;
    width: 2px; height: 2px; overflow: visible;
    pointer-events: none;
}
.nb-edge {
    fill: none; stroke: url(#nbGrad); stroke-width: 2.4;
    pointer-events: none;
    filter: drop-shadow(0 0 5px rgba(139, 92, 246, 0.45));
    transition: stroke-width 0.15s ease;
}
.nb-edge.selected {
    stroke: #22D3EE; stroke-width: 3.2;
    filter: drop-shadow(0 0 7px rgba(34, 211, 238, 0.7));
}
.nb-edge-hit { fill: none; stroke: transparent; stroke-width: 18; pointer-events: stroke; cursor: pointer; }
.nb-ghost {
    fill: none; stroke: #22D3EE; stroke-width: 2.2;
    stroke-dasharray: 8 7; pointer-events: none;
    filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.55));
    animation: nb-dash 0.45s linear infinite;
}
@keyframes nb-dash { to { stroke-dashoffset: -15; } }
.nb-edge-del {
    position: absolute; width: 26px; height: 26px; border-radius: 50%;
    background: rgba(239, 68, 68, 0.94); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; cursor: pointer; z-index: 7;
    box-shadow: 0 3px 14px rgba(239, 68, 68, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.75);
    animation: nb-pop 0.16s ease;
}
@keyframes nb-pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------- Node cards ---------------- */
.nb-node {
    position: absolute; width: 460px;
    background: rgba(20, 20, 31, 0.93);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 15px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
    user-select: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.nb-node:hover { border-color: rgba(255, 255, 255, 0.17); }
.nb-node.selected {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3), 0 14px 36px rgba(124, 58, 237, 0.3);
}
.nb-strip { height: 3px; border-radius: 15px 15px 0 0; }
.nb-text .nb-strip { background: linear-gradient(90deg, #7C3AED, #A78BFA); }
.nb-image .nb-strip { background: linear-gradient(90deg, #0891B2, #22D3EE); }
.nb-video .nb-strip { background: linear-gradient(90deg, #F59E0B, #FB923C); }

.nb-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 4px; }
.nb-ic {
    width: 26px; height: 26px; border-radius: 8px; flex: none;
    display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.nb-text .nb-ic { background: rgba(139, 92, 246, 0.16); color: #A78BFA; }
.nb-image .nb-ic { background: rgba(6, 182, 212, 0.14); color: #22D3EE; }
.nb-video .nb-ic { background: rgba(245, 158, 11, 0.14); color: #FBBF24; }
.nb-ord {
    flex: none; font-size: 10px; font-weight: 800; letter-spacing: 0.3px;
    color: var(--text-3); background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px; padding: 1px 6px; cursor: help;
}
/* Subject / Scene badge on image node headers. Subject = engine Image 1
 * (amber, star); Scene = environment reference (cyan, easel). */
.nb-role {
    flex: none; display: inline-flex; align-items: center; gap: 3px;
    font-size: 9.5px; font-weight: 800; letter-spacing: 0.4px;
    border-radius: 20px; padding: 1.5px 7px; cursor: pointer;
    border: 1px solid transparent; font-family: inherit; line-height: 1.5;
    transition: filter .15s ease, transform .1s ease;
}
.nb-role i { font-size: 9px; }
.nb-role:hover { filter: brightness(1.15); }
.nb-role:active { transform: scale(0.96); }
.nb-role.is-subject { background: rgba(245, 158, 11, 0.16); color: #FBBF24; border-color: rgba(245, 158, 11, 0.38); }
.nb-role.is-scene { background: rgba(6, 182, 212, 0.12); color: #67E8F9; border-color: rgba(6, 182, 212, 0.26); }
.nb-label {
    flex: 1; min-width: 0; background: transparent; border: 0; outline: 0;
    color: var(--text-1); font-weight: 600; font-size: 13px;
}
.nb-label::placeholder { color: var(--text-3); font-weight: 500; }
.nb-del {
    flex: none; width: 22px; height: 22px; border-radius: 7px;
    color: var(--text-3); font-size: 11px; opacity: 0;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.nb-node:hover .nb-del { opacity: 1; }
.nb-del:hover { background: rgba(239, 68, 68, 0.16); color: #F87171; }

.nb-body { padding: 6px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.nb-ta {
    width: 100%; min-height: 280px;
    background: rgba(15, 15, 24, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px; color: #E5E7EB;
    font-size: 13.5px; line-height: 1.6; padding: 10px 11px;
    resize: vertical; outline: 0; user-select: text;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
/* dark scrollbar - the browser default paints a white gutter */
.nb-ta::-webkit-scrollbar { width: 8px; height: 8px; }
.nb-ta::-webkit-scrollbar-track { background: transparent; }
.nb-ta::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 4px; }
.nb-ta::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }
.nb-ta:focus { border-color: rgba(139, 92, 246, 0.55); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12); }
.nb-ta::placeholder { color: var(--text-3); }
.nb-ta.nb-cap { min-height: 150px; }

/* Read-only line under an image/video node's caption: the keywords its last
   generation actually used (hover for the full prompt). */
.nb-lastprompt {
    margin-top: 8px; padding: 6px 10px;
    border: 1px dashed var(--border); border-radius: 8px;
    font-size: 11px; line-height: 1.5; color: var(--muted, #8b90a0);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    cursor: default;
}
.nb-lastprompt .bi { margin-right: 4px; opacity: .7; }

/* Reference thumbnails: images wired into an image/video node, shown above
   its text box. Click inserts the engine token (Image1, ...) into the text. */
.nb-refs-wrap { display: none; }
.nb-refs-wrap.on { display: block; }
.nb-refs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.nb-ref {
    position: relative; width: 66px; flex: none;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-2, #14151d); padding: 0; cursor: pointer; overflow: hidden;
    transition: border-color .15s ease, transform .15s ease;
}
.nb-ref:hover { border-color: rgba(139, 92, 246, 0.7); transform: translateY(-1px); }
.nb-ref img { width: 66px; height: 48px; object-fit: cover; display: block; pointer-events: none; }
.nb-ref span {
    display: block; font-size: 10px; line-height: 1.5; text-align: center;
    color: var(--text-2); padding: 2px 0 3px; font-weight: 600;
}
.nb-ref.is-subject { border-color: rgba(245, 158, 11, 0.55); }
.nb-ref.is-subject span { color: #f59e0b; }

/* Node body (caption, actions, spec pickers) is always visible so the node
   height stays fixed and the input/output ports keep a stable position while
   dragging connecting lines. */
.nb-media { position: relative; border-radius: 10px; overflow: hidden; background: #000; }
.nb-media .nb-open { display: block; cursor: zoom-in; }
.nb-media img { width: 100%; display: block; pointer-events: none; }
.nb-media video { width: 100%; max-height: 190px; display: block; background: #000; }
.nb-media .nb-media-name {
    display: block; padding: 5px 8px; font-size: 10.5px; color: var(--text-3);
    background: rgba(10, 10, 15, 0.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nb-tools {
    position: absolute; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: flex-end; gap: 6px;
    padding: 6px 7px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0));
}
.nb-tools .nb-dl,
.nb-change {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 4px 10px; border-radius: 20px;
    background: rgba(10, 10, 15, 0.8); color: #E5E7EB;
    font-size: 11px; font-weight: 600; line-height: 1.2;
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(4px);
    transition: var(--transition);
    text-decoration: none; cursor: pointer;
}
.nb-tools .nb-dl { padding: 4px 8px; font-size: 12px; }
.nb-tools .nb-dl:hover,
.nb-change:hover { color: #fff; border-color: rgba(139, 92, 246, 0.6); }

.nb-pick {
    width: 100%; aspect-ratio: 4 / 3;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    border-radius: 11px; padding: 0 14px;
    border: 1.5px dashed rgba(255, 255, 255, 0.16);
    background: rgba(15, 15, 24, 0.5); color: var(--text-2);
    transition: var(--transition); text-align: left;
}
.nb-pick:hover {
    border-color: rgba(139, 92, 246, 0.55); color: #fff;
    background: rgba(139, 92, 246, 0.07); box-shadow: var(--glow-sm);
}
.np-ic {
    width: 34px; height: 34px; border-radius: 10px; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.05); font-size: 16px;
}
.nb-pick .np-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nb-pick .np-tx b { font-size: 12.5px; color: var(--text-1); font-weight: 600; }
.nb-pick .np-tx em { font-style: normal; font-size: 10.5px; color: var(--text-3); }

/* ---------------- Node action footer (Enhance / Generate) ---------------- */
.nb-actions { display: flex; gap: 7px; margin-top: 1px; }
.nb-actions button {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 8px; border-radius: 9px; font-size: 11.5px; font-weight: 700;
    transition: var(--transition); white-space: nowrap;
}
.nb-actions button i { font-size: 12px; }
.nb-enhance {
    color: #C4B5FD; background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.42);
}
.nb-enhance:hover { background: rgba(139, 92, 246, 0.22); color: #fff; border-color: rgba(139, 92, 246, 0.7); }
.nb-enhance.busy { opacity: 0.55; pointer-events: none; }
.nb-gen {
    color: #fff; background: var(--grad);
    border: 1px solid transparent;
    box-shadow: 0 3px 12px rgba(124, 58, 237, 0.3);
}
.nb-gen:hover { background: var(--grad-hover); transform: translateY(-1px); box-shadow: var(--glow); }
.nb-gen:disabled, .nb-gen.busy { opacity: 0.55; pointer-events: none; transform: none; box-shadow: none; }
.nb-cost {
    margin-left: auto; font-size: 10.5px; font-weight: 800; line-height: 1.4;
    background: rgba(251, 191, 36, 0.15); color: #FBBF24;
    border-radius: 20px; padding: 1px 7px; white-space: nowrap;
}

/* ---------------- Node busy mask (Generate / Enhance) ---------------- */
.nb-node.nb-busy { border-color: rgba(139, 92, 246, 0.55); }
.nb-mask {
    position: absolute; inset: 0; z-index: 5;
    border-radius: 15px; overflow: hidden; pointer-events: none;
    background: rgba(10, 10, 18, 0.62);
    backdrop-filter: blur(2.5px); -webkit-backdrop-filter: blur(2.5px);
    display: flex; align-items: center; justify-content: center;
    animation: nb-mask-in 0.18s ease;
}
.nb-mask::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 55%;
    background: linear-gradient(100deg, transparent, rgba(167, 139, 250, 0.26), transparent);
    animation: nb-sweep 1.5s linear infinite;
}
.nb-mask-c {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-align: center; padding: 0 16px;
}
.nb-mask-spin {
    width: 26px; height: 26px; border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, 0.14);
    border-top-color: #A78BFA; border-right-color: #22D3EE;
    animation: nb-spin 0.85s linear infinite;
}
.nb-mask-tx { font-size: 12.5px; font-weight: 700; color: #fff; }
.nb-mask-sub { font-style: normal; font-size: 10.5px; color: var(--text-3); }
@keyframes nb-spin { to { transform: rotate(360deg); } }
@keyframes nb-sweep { from { transform: translateX(-120%); } to { transform: translateX(240%); } }
@keyframes nb-mask-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- Node spec pickers (image/video resolution + duration) ---------------- */
.nb-spec {
    display: flex; flex-direction: column; gap: 5px;
    margin-top: 2px; padding: 8px 9px;
    background: rgba(15, 15, 24, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}
.nb-spec-label {
    display: flex; align-items: center; gap: 5px;
    font-size: 10.5px; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.nb-spec-label i { font-size: 11px; color: #A78BFA; }
.nb-spec select {
    width: 100%; padding: 7px 9px;
    background: rgba(20, 20, 31, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9px; color: #E5E7EB; font-size: 12px;
    outline: 0; cursor: pointer; transition: border-color 0.15s ease;
}
.nb-spec select:hover { border-color: rgba(255, 255, 255, 0.2); }
.nb-spec select:focus { border-color: rgba(139, 92, 246, 0.55); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12); }
/* duration + aspect ratio sit side by side under the resolution select */
.nb-spec-row { display: flex; gap: 6px; }
.nb-spec-row .nb-spec-cell { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 5px; }

/* ---------------- Ports ---------------- */
.nb-port {
    position: absolute; top: 50%; z-index: 3;
    width: 16px; height: 16px; border-radius: 50%;
    background: #0F0F18; border: 2px solid #8B5CF6;
    margin-top: -8px; cursor: crosshair;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.nb-port.nb-in { left: -8.5px; border-color: #06B6D4; }
.nb-port.nb-out { right: -8.5px; border-color: #8B5CF6; }
.nb-port.nb-out:hover { transform: scale(1.4); box-shadow: 0 0 12px rgba(139, 92, 246, 0.75); }
.nb-port.nb-in:hover { transform: scale(1.4); box-shadow: 0 0 12px rgba(6, 182, 212, 0.75); }
.nb-port.nb-hot {
    transform: scale(1.5); background: #22D3EE;
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.95);
}

/* Right-hand "+" button: create a connected node of any type in one tap. */
.nb-branch {
    position: absolute; right: -17px; top: 50%; margin-top: 36px; z-index: 4;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--grad); color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.85);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; line-height: 1; cursor: pointer;
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.5);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    opacity: 0.4;
}
.nb-node:hover .nb-branch { opacity: 1; }
.nb-branch:hover { transform: scale(1.22); box-shadow: 0 0 14px rgba(139, 92, 246, 0.85); }

/* ---------------- Branch type menu (attached to the + button) ---------------- */
.cv-branch-menu {
    position: fixed; z-index: 1600; min-width: 148px;
    background: #171722; border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 13px; padding: 6px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    animation: cv-pop 0.15s ease;
}
.cv-branch-menu .bm-h {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px;
    color: var(--text-3); padding: 4px 10px 6px;
}
.cv-branch-item {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 8px 10px; border-radius: 9px; color: var(--text-1);
    font-size: 12.5px; font-weight: 600; transition: var(--transition); text-align: left;
}
.cv-branch-item i { font-size: 14px; width: 16px; text-align: center; }
.cv-branch-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.cv-branch-item.bt-text i { color: #A78BFA; }
.cv-branch-item.bt-image i { color: #22D3EE; }
.cv-branch-item.bt-video i { color: #FBBF24; }

/* ---------------- Empty guide ---------------- */
.nb-empty {
    position: absolute; inset: 0; z-index: 1;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none; padding: 20px;
}
.nb-guide {
    background: rgba(20, 20, 31, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-radius: 22px; padding: 32px 36px; max-width: 470px; text-align: center;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}
.nb-guide h3 { margin: 0 0 7px; font-size: 18px; font-weight: 700; }
.nb-guide h3 span {
    background: var(--grad-text);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.nb-guide p { margin: 0 0 20px; color: var(--text-2); font-size: 12.5px; line-height: 1.65; }
.nb-steps { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.nb-step {
    flex: 1; min-width: 116px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px; padding: 15px 10px;
}
.nb-step i { font-size: 21px; display: block; margin: 0 auto 9px; }
.nb-step b { font-size: 12px; display: block; margin-bottom: 4px; }
.nb-step em { font-style: normal; font-size: 10.5px; color: var(--text-3); line-height: 1.5; display: block; }
.nb-step.s1 i { color: #A78BFA; }
.nb-step.s2 i { color: #22D3EE; }
.nb-step.s3 i { color: #FBBF24; }
/* clickable empty-state blocks -> create a node directly */
.nb-step.nb-act {
    pointer-events: auto; cursor: pointer;
    font: inherit; color: inherit; text-align: center;
    transition: background .15s, border-color .15s, transform .15s;
}
.nb-step.nb-act:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}
.nb-step.nb-act:active { transform: translateY(0); }
.nb-step.nb-act:focus-visible { outline: 2px solid rgba(139, 92, 246, 0.7); outline-offset: 2px; }

/* ---------------- Bottom status pills ---------------- */
.cv-hint {
    position: absolute; left: 16px; bottom: 14px; z-index: 4;
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.cv-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 20px;
    background: rgba(13, 13, 20, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-3); font-size: 11px; font-weight: 500;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.cv-pill b { color: var(--text-2); font-weight: 700; }
.cv-pill .act { color: var(--text-2); cursor: pointer; font-weight: 600; transition: color 0.15s; }
.cv-pill .act:hover { color: #fff; }
.cv-pill.danger .act:hover { color: #F87171; }

/* ---------------- Library picker modal (custom overlay, no bootstrap dep) ---- */
.cv-lib-overlay {
    position: fixed; inset: 0; z-index: 1500;
    background: rgba(5, 5, 10, 0.72);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: cv-fade 0.18s ease;
}
.cv-lib-modal {
    width: min(720px, 100%); max-height: min(86vh, 760px);
    display: flex; flex-direction: column;
    background: #14141F;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
    animation: cv-pop 0.18s ease;
}
@keyframes cv-fade { from { opacity: 0; } }
@keyframes cv-pop { from { transform: translateY(14px) scale(0.98); opacity: 0; } }
.cv-lib-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px 10px;
}
.cv-lib-head h5 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cv-lib-head h5 i { color: #22D3EE; }
.cv-lib-close {
    width: 30px; height: 30px; border-radius: 9px;
    color: var(--text-3); display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.cv-lib-close:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.cv-lib-body { padding: 2px 18px 12px; overflow-y: auto; flex: 1; }
.cv-lib-foot {
    display: flex; justify-content: flex-end; gap: 9px;
    padding: 12px 18px 16px; border-top: 1px solid var(--border);
}
.cv-lib-group {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.7px; color: var(--text-3);
    margin: 12px 0 8px; display: flex; align-items: center; gap: 6px;
}
.cv-lib-group .cnt { color: var(--text-3); font-weight: 500; text-transform: none; letter-spacing: 0; }
.cv-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
.cv-lib-tile {
    position: relative; aspect-ratio: 4 / 3; width: 100%;
    border-radius: 10px; overflow: hidden; cursor: pointer;
    background: var(--bg-input); border: 2px solid transparent;
    transition: var(--transition); padding: 0;
}
.cv-lib-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv-lib-tile:hover { transform: translateY(-2px); }
.cv-lib-tile.selected {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.28), 0 4px 12px rgba(139, 92, 246, 0.34);
}
.cv-lib-ck {
    position: absolute; top: 5px; right: 5px; z-index: 2;
    width: 20px; height: 20px; border-radius: 50%;
    background: #8B5CF6; color: #fff;
    display: none; align-items: center; justify-content: center;
    font-size: 11px; border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.45);
}
.cv-lib-tile.selected .cv-lib-ck { display: flex; }
.cv-lib-up {
    aspect-ratio: 4 / 3; width: 100%;
    border-radius: 10px; border: 1.5px dashed rgba(255, 255, 255, 0.16);
    display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 5px;
    color: var(--text-3); font-size: 11px; font-weight: 600;
    cursor: pointer; transition: var(--transition); background: transparent; padding: 0;
}
.cv-lib-up i { font-size: 19px; }
.cv-lib-up:hover { border-color: rgba(139, 92, 246, 0.55); color: var(--text-2); }
.cv-lib-up.busy { opacity: 0.55; pointer-events: none; }
.cv-lib-empty { color: var(--text-3); font-size: 12px; padding: 10px 2px; }
.cv-btn-ghost {
    padding: 8px 18px; border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--text-2); font-size: 13px; font-weight: 600; transition: var(--transition);
}
.cv-btn-ghost:hover { color: #fff; border-color: rgba(255, 255, 255, 0.3); }

/* ---------------- Styled confirm dialog (Enhance / Generate / Clear) ---- */
.cv-confirm-overlay {
    position: fixed; inset: 0; z-index: 1600;
    background: rgba(5, 5, 10, 0.72);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: cv-fade 0.18s ease;
}
.cv-confirm-modal {
    width: min(400px, 100%);
    background: #14141F;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
    padding: 24px 22px 20px;
    text-align: center;
    animation: cv-pop 0.18s ease;
}
.cv-confirm-icon {
    width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center; font-size: 24px;
    background: rgba(139, 92, 246, 0.14); color: #A78BFA;
}
.cv-confirm-modal.danger .cv-confirm-icon { background: rgba(239, 68, 68, 0.14); color: #F87171; }
.cv-confirm-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.cv-confirm-body { margin: 0 0 16px; color: var(--text-2); font-size: 12.5px; line-height: 1.6; }
.cv-confirm-body b { color: var(--text-1); }
.cv-confirm-cost {
    display: inline-flex; align-items: baseline; gap: 8px;
    margin: 0 auto 18px; padding: 10px 16px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.18), rgba(6, 182, 212, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.4); border-radius: 12px;
    font-size: 13px; font-weight: 700;
}
.cv-confirm-cost b {
    font-size: 20px; font-weight: 800; line-height: 1;
    background: linear-gradient(90deg, #A78BFA, #22D3EE);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.cv-confirm-cost small { font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: 0.3px; }
.cv-confirm-cost .cost-orig {
    font-size: 13px; font-weight: 700;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.75); text-decoration-thickness: 2px;
}
.cv-confirm-cost .cost-off {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 176, 32, 0.22), rgba(255, 94, 58, 0.26));
    border: 1px solid rgba(255, 176, 32, 0.6);
    color: #FFC24D; font-size: 11px; font-weight: 800; letter-spacing: 0.4px;
    white-space: nowrap;
    animation: cvOffPulse 2.4s ease-in-out infinite;
}
.cv-confirm-cost .cost-off i { font-size: 10px; }
@keyframes cvOffPulse {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 176, 32, 0); }
    50% { box-shadow: 0 0 14px rgba(255, 176, 32, 0.45); }
}
.cv-confirm-actions { display: flex; gap: 10px; justify-content: center; }
.cv-confirm-actions .btn-grad,
.cv-confirm-actions .cv-btn-ghost { min-width: 124px; padding: 9px 20px; }
.cv-confirm-actions .btn-grad.danger {
    background: linear-gradient(135deg, #EF4444, #F97316);
    box-shadow: 0 3px 12px rgba(239, 68, 68, 0.35);
}
.cv-confirm-actions .btn-grad.danger:hover { background: linear-gradient(135deg, #F87171, #FB923C); }

/* ---------------- Responsive ---------------- */
@media (max-width: 899px) {
    .cv-tool-btn span { display: none; }
    .cv-tool-btn { padding: 8px 10px; }
    .cv-title span.t-long { display: none; }
    .cv-toolbar { gap: 8px; padding: 8px 12px; }
    .cv-hint { max-width: 70%; }
}
@media (max-width: 575px) {
    .cv-zval { display: none; }
    .cv-save em { display: none; }
}
