:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-mono: 'SF Mono', ui-monospace, 'Cascadia Code', 'Fira Code', monospace;

    --n-0: #ffffff; --n-25: #fafafa; --n-50: #f5f5f7;
    --n-100: #ebebef; --n-150: #e0e0e6; --n-200: #d1d1d9;
    --n-300: #b4b4bf; --n-400: #8e8e9d; --n-500: #6b6b7b;
    --n-600: #4b4b58; --n-700: #353541; --n-800: #23232d;
    --n-900: #16161d; --n-950: #0e0e13;

    --a-700: #1d4ed8; --a-600: #2563eb; --a-500: #3b82f6;
    --a-400: #60a5fa; --a-300: #93bbfd; --a-200: #bfdbfe;
    --a-100: #dbeafe; --a-50: #eff6ff;
    --a-glow: rgba(37,99,235,0.12);
    --a-surface: rgba(37,99,235,0.06);

    --green: #16a34a; --green-bg: #f0fdf4;
    --amber: #d97706; --amber-bg: #fffbeb;
    --red: #dc2626; --red-bg: #fef2f2;

    --b03: rgba(0,0,0,0.03); --b05: rgba(0,0,0,0.05);
    --b07: rgba(0,0,0,0.07); --b10: rgba(0,0,0,0.10);
    --b14: rgba(0,0,0,0.14); --b20: rgba(0,0,0,0.20);

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --fast: 100ms; --norm: 180ms; --slow: 320ms;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%; font-family: var(--font-sans);
    background: var(--n-50); color: var(--n-800);
    -webkit-font-smoothing: antialiased; overflow: hidden;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

::selection { background: rgba(37,99,235,0.2); }

/* ════════ LAYOUT ════════ */
#canvas-app { height: 100%; display: flex; }

/* ════════ SIDEBAR ════════ */
.cv-sidebar {
    width: 240px; flex-shrink: 0;
    background: var(--n-0);
    border-right: 1px solid var(--n-150);
    display: flex; flex-direction: column;
    z-index: 20;
    transition: transform var(--slow) var(--ease);
}

.cv-sb-head {
    padding: 16px 16px 12px;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--n-100);
}

.cv-sb-logo {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--a-600);
    display: grid; place-items: center;
    box-shadow: 0 1px 3px rgba(37,99,235,0.3);
}

.cv-sb-logo svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cv-sb-title { font-size: 14px; font-weight: 700; letter-spacing: -0.3px; color: var(--n-900); }

.cv-sb-section {
    padding: 14px 14px 6px;
    font-size: 10px; font-weight: 700; color: var(--n-400);
    text-transform: uppercase; letter-spacing: 1px;
}

.cv-sb-list { flex: 1; overflow-y: auto; padding: 2px 8px; }
.cv-sb-list::-webkit-scrollbar { width: 0; }

.cv-ws-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 7px;
    font-size: 13px; color: var(--n-500); cursor: pointer;
    transition: all var(--fast) ease; user-select: none;
}

.cv-ws-item:hover { background: var(--b05); color: var(--n-700); }
.cv-ws-item.active { background: var(--a-50); color: var(--a-700); font-weight: 500; }

.cv-ws-item svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; flex-shrink: 0; }

.cv-ws-add {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; margin: 4px 8px;
    border-radius: 7px; border: 1px dashed var(--n-200);
    font: 500 12px var(--font-sans); color: var(--n-400);
    cursor: pointer; background: transparent;
    transition: all var(--norm) var(--ease);
    width: calc(100% - 16px);
}

.cv-ws-add:hover { border-color: var(--a-300); color: var(--a-600); background: var(--a-50); }
.cv-ws-add svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

.cv-sb-footer {
    padding: 12px 14px; border-top: 1px solid var(--n-100);
    display: flex; align-items: center; gap: 8px;
}

.cv-sb-chat-link {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 7px;
    font: 500 12px var(--font-sans); color: var(--n-500);
    text-decoration: none; width: 100%;
    transition: all var(--fast) ease;
}

.cv-sb-chat-link:hover { background: var(--b05); color: var(--n-700); }
.cv-sb-chat-link svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }

/* ════════ MAIN AREA ════════ */
.cv-main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* ════════ TAB BAR ════════ */
.cv-tabbar {
    display: flex; align-items: stretch;
    height: 38px; flex-shrink: 0;
    background: var(--n-25);
    border-bottom: 1px solid var(--n-150);
    padding: 0 4px;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
    z-index: 11;
}
.cv-tabbar::-webkit-scrollbar { display: none; }

.cv-tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 0 14px; height: 100%;
    font: 500 12px var(--font-sans); color: var(--n-500);
    white-space: nowrap; cursor: pointer;
    border-right: 1px solid var(--n-100);
    position: relative;
    transition: color var(--fast) ease, background var(--fast) ease;
    user-select: none; flex-shrink: 0;
}
.cv-tab:hover { background: var(--b05); color: var(--n-700); }

.cv-tab.active {
    background: var(--n-0); color: var(--n-900); font-weight: 600;
}
.cv-tab.active::after {
    content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
    height: 2px; background: var(--a-600); border-radius: 2px 2px 0 0;
}

.cv-tab-dot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.cv-tab-dot.none { display: none; }
.cv-tab-dot.idle { background: var(--n-300); }
.cv-tab-dot.running { background: var(--green); animation: tabDotPulse 1.5s ease-in-out infinite; }
.cv-tab-dot.error { background: var(--red); }

@keyframes tabDotPulse {
    0%, 100% { opacity: 1; } 50% { opacity: 0.4; }
}

.cv-tab-name {
    max-width: 120px; overflow: hidden; text-overflow: ellipsis;
}

.cv-tab-close {
    width: 18px; height: 18px; border-radius: 4px;
    border: none; background: transparent; color: var(--n-300);
    cursor: pointer; display: grid; place-items: center;
    flex-shrink: 0; opacity: 0;
    transition: all var(--fast) ease;
}
.cv-tab:hover .cv-tab-close { opacity: 1; }
.cv-tab.active .cv-tab-close { opacity: 0.6; }
.cv-tab-close:hover { background: var(--red-bg); color: var(--red); opacity: 1 !important; }
.cv-tab-close svg { width: 10px; height: 10px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; }

.cv-tab-add {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 100%; flex-shrink: 0;
    border: none; background: transparent; color: var(--n-400);
    cursor: pointer; transition: all var(--fast) ease;
}
.cv-tab-add:hover { color: var(--a-600); background: var(--a-surface); }
.cv-tab-add svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.cv-tabbar-right {
    margin-left: auto; display: flex; align-items: center; gap: 2px;
    padding-right: 8px; flex-shrink: 0;
}

.cv-tabbar-btn {
    width: 30px; height: 28px; border-radius: 6px;
    border: none; background: transparent; color: var(--n-400);
    cursor: pointer; display: grid; place-items: center;
    transition: all var(--fast) ease;
}
.cv-tabbar-btn:hover { background: var(--b07); color: var(--n-700); }
.cv-tabbar-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.cv-tabbar-sep { width: 1px; height: 18px; background: var(--n-200); margin: 0 4px; flex-shrink: 0; }

.cv-layout-toggle {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; height: 28px; border-radius: 6px;
    border: 1px solid var(--n-200); background: var(--n-0);
    font: 500 11px var(--font-sans); color: var(--n-500);
    cursor: pointer; transition: all var(--fast) ease;
}
.cv-layout-toggle:hover { border-color: var(--a-300); color: var(--a-600); background: var(--a-surface); }
.cv-layout-toggle.active { border-color: var(--a-400); color: var(--a-600); background: var(--a-50); }
.cv-layout-toggle svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ════════ GRID LAYOUT MODE ════════ */
#cv-viewport.grid-mode {
    overflow-y: auto; overflow-x: hidden;
    cursor: default;
    background: var(--n-50);
}

#cv-viewport.grid-mode #cv-world {
    position: relative; width: 100%; height: auto;
    transform: none !important;
    display: flex; flex-wrap: wrap; gap: 16px;
    padding: 20px;
    align-content: flex-start;
}

#cv-viewport.grid-mode .cv-node {
    position: relative !important;
    left: auto !important; top: auto !important;
    transform: none !important;
    flex-shrink: 0;
}

#cv-viewport.grid-mode .cv-node.terminal {
    width: calc(50% - 8px) !important;
    height: 420px !important;
    min-width: 400px;
}

#cv-viewport.grid-mode .cv-node:not(.terminal):not(.sticky) {
    width: calc(50% - 8px) !important;
    height: 440px !important;
    min-width: 340px;
}

#cv-viewport.grid-mode .cv-node.sticky {
    width: 220px !important; height: 180px !important;
}

.cv-main.grid-active .cv-toolbar { display: none; }
.cv-main.grid-active .cv-zoom { display: none; }

#cv-viewport.grid-mode .cv-edges-layer,
#cv-viewport.grid-mode .cv-drawings-layer { display: none; }
#cv-viewport.grid-mode .cv-node-resize { display: none; }
#cv-viewport.grid-mode .cv-node-head { cursor: default; }

@media (max-width: 1100px) {
    #cv-viewport.grid-mode .cv-node.terminal,
    #cv-viewport.grid-mode .cv-node:not(.terminal):not(.sticky) {
        width: 100% !important;
        min-width: 0;
    }
}

/* ════════ TOOLBAR ════════ */
.cv-toolbar {
    position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
    z-index: 10;
    display: flex; align-items: center; gap: 2px;
    padding: 4px; background: var(--n-0);
    border: 1px solid var(--n-150);
    border-radius: 12px;
    box-shadow: 0 2px 12px var(--b10);
}

.cv-tb-btn {
    width: 36px; height: 34px; border-radius: 8px;
    border: none; background: transparent; color: var(--n-500);
    cursor: pointer; display: grid; place-items: center;
    transition: all var(--fast) ease;
    position: relative;
}

.cv-tb-btn:hover { background: var(--b07); color: var(--n-700); }
.cv-tb-btn.active { background: var(--a-50); color: var(--a-600); }
.cv-tb-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.cv-tb-sep { width: 1px; height: 24px; background: var(--n-150); margin: 0 2px; }

.cv-tb-btn[title]::after {
    content: attr(title);
    position: absolute; top: calc(100% + 6px); left: 50%;
    transform: translateX(-50%); white-space: nowrap;
    padding: 4px 8px; border-radius: 6px;
    background: var(--n-800); color: var(--n-0);
    font-size: 11px; font-weight: 500;
    pointer-events: none; opacity: 0;
    transition: opacity var(--fast) ease;
}

.cv-tb-btn:hover[title]::after { opacity: 1; }

/* ════════ ZOOM CONTROLS ════════ */
.cv-zoom {
    position: absolute; bottom: 16px; right: 16px; z-index: 10;
    display: flex; align-items: center; gap: 4px;
    padding: 4px; background: var(--n-0);
    border: 1px solid var(--n-150); border-radius: 10px;
    box-shadow: 0 2px 8px var(--b07);
}

.cv-zoom-btn {
    width: 32px; height: 30px; border-radius: 7px;
    border: none; background: transparent; color: var(--n-500);
    cursor: pointer; display: grid; place-items: center;
    transition: all var(--fast) ease; font: 600 12px var(--font-sans);
}

.cv-zoom-btn:hover { background: var(--b07); color: var(--n-700); }
.cv-zoom-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

.cv-zoom-val {
    min-width: 40px; text-align: center;
    font: 600 11px var(--font-sans); color: var(--n-500);
    user-select: none;
}

/* ════════ VIEWPORT & WORLD ════════ */
#cv-viewport {
    flex: 1; overflow: hidden; position: relative;
    cursor: grab;
    background:
        radial-gradient(circle, var(--n-200) 1px, transparent 1px);
    background-size: 24px 24px;
}

#cv-viewport.panning { cursor: grabbing; }
#cv-viewport.tool-draw { cursor: crosshair; }

#cv-world {
    position: absolute; left: 0; top: 0;
    width: 0; height: 0;
    transform-origin: 0 0;
    will-change: transform;
}

/* ════════ CANVAS NODE ════════ */
.cv-node {
    position: absolute;
    background: var(--n-0);
    border: 1px solid var(--n-150);
    border-radius: 14px;
    box-shadow: 0 2px 8px var(--b07);
    display: flex; flex-direction: column;
    overflow: hidden;
    transition: box-shadow var(--fast) ease;
    user-select: none;
}

.cv-node:hover { box-shadow: 0 4px 20px var(--b14); }
.cv-node.selected { border-color: var(--a-400); box-shadow: 0 0 0 2px var(--a-glow), 0 4px 20px var(--b14); }
.cv-node.running { border-color: var(--a-400); }
.cv-node.error { border-color: var(--red); }

/* ── Node header ── */
.cv-node-head {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    background: var(--n-25);
    border-bottom: 1px solid var(--n-100);
    cursor: move;
    flex-shrink: 0;
}

.cv-node-status {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}

.cv-node-status.idle { background: var(--n-300); }
.cv-node-status.running { background: var(--a-500); animation: statusPulse 1.5s ease-in-out infinite; }
.cv-node-status.error { background: var(--red); }

@keyframes statusPulse {
    0%, 100% { opacity: 1; box-shadow: none; }
    50% { opacity: 0.6; box-shadow: 0 0 8px var(--a-400); }
}

.cv-node-title {
    flex: 1; font-size: 13px; font-weight: 600;
    color: var(--n-800); min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.cv-node-actions { display: flex; gap: 2px; }

.cv-node-btn {
    width: 26px; height: 26px; border-radius: 6px;
    border: none; background: transparent; color: var(--n-400);
    cursor: pointer; display: grid; place-items: center;
    transition: all var(--fast) ease;
}

.cv-node-btn:hover { background: var(--b07); color: var(--n-700); }
.cv-node-btn[data-action="reset"]:hover { background: var(--amber-bg); color: var(--amber); }
.cv-node-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Session badge ── */
.cv-session-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 10px;
    font: 500 10px var(--font-mono);
    color: var(--n-400); background: var(--n-50);
    border: 1px solid var(--n-150);
    cursor: default; user-select: none;
    transition: all var(--fast) ease;
    max-height: 22px;
}
.cv-session-badge svg {
    width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}
.cv-session-badge.active {
    color: var(--green); background: var(--green-bg);
    border-color: #86efac; cursor: pointer;
}
.cv-session-badge.active:hover {
    background: #dcfce7; border-color: var(--green);
}
.cv-session-badge.copied {
    color: var(--a-600); background: var(--a-50);
    border-color: var(--a-300);
}
.cv-session-label { letter-spacing: 0.3px; }

/* ── Message count ── */
.cv-msg-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; font: 600 10px var(--font-sans);
    background: var(--n-100); color: var(--n-500);
    line-height: 1;
}

/* ── Agent chat body ── */
.cv-node-chat {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 10px 12px;
    font-size: 13px; line-height: 1.65;
    color: var(--n-600);
    user-select: text;
}

.cv-node-chat::-webkit-scrollbar { width: 4px; }
.cv-node-chat::-webkit-scrollbar-thumb { background: var(--b10); border-radius: 2px; }

.cv-chat-msg { margin-bottom: 10px; animation: msgFade var(--norm) var(--ease); }
.cv-chat-msg:last-child { margin-bottom: 0; }

@keyframes msgFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.cv-chat-msg.user { text-align: right; }
.cv-chat-msg .role { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--n-400); margin-bottom: 2px; }
.cv-chat-msg.assistant .role { color: var(--a-600); }

.cv-chat-msg .bubble {
    display: inline-block; max-width: 95%;
    padding: 6px 10px; border-radius: 8px;
    text-align: left; word-break: break-word;
}

.cv-chat-msg.user .bubble { background: var(--a-50); color: var(--a-700); }
.cv-chat-msg.assistant .bubble { background: var(--n-50); color: var(--n-700); }

.cv-chat-msg .bubble strong { font-weight: 600; color: var(--n-800); }
.cv-chat-msg .bubble code { font-family: var(--font-mono); font-size: 0.88em; background: var(--b05); padding: 1px 5px; border-radius: 4px; }
.cv-chat-msg .bubble pre { background: var(--n-25); border: 1px solid var(--n-100); padding: 8px 10px; border-radius: 6px; overflow-x: auto; margin: 6px 0; font-size: 12px; }

/* Typing dots */
.cv-typing { display: flex; gap: 4px; padding: 6px 0; }
.cv-typing span { width: 6px; height: 6px; background: var(--n-300); border-radius: 50%; animation: cvDot 1.4s ease-in-out infinite; }
.cv-typing span:nth-child(2) { animation-delay: .15s; }
.cv-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes cvDot {
    0%, 80%, 100% { opacity: .2; transform: scale(.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* ── Node input ── */
.cv-node-input {
    display: flex; align-items: flex-end; gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--n-100);
    background: var(--n-0);
    flex-shrink: 0;
}

.cv-node-input textarea {
    flex: 1; border: 1px solid var(--n-200);
    border-radius: 8px; padding: 7px 10px;
    font: 400 13px/1.5 var(--font-sans);
    color: var(--n-800); background: var(--n-0);
    resize: none; outline: none;
    min-height: 20px; max-height: 80px;
    transition: border-color var(--fast) ease;
}

.cv-node-input textarea::placeholder { color: var(--n-300); }
.cv-node-input textarea:focus { border-color: var(--a-400); }

.cv-node-send {
    width: 32px; height: 32px; border-radius: 8px;
    border: none; background: var(--n-100); color: var(--n-400);
    cursor: pointer; display: grid; place-items: center;
    transition: all var(--fast) var(--ease);
    flex-shrink: 0;
}

.cv-node-send.on { background: var(--a-600); color: #fff; }
.cv-node-send.on:hover { background: var(--a-500); }
.cv-node-send svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }

/* ── Resize handle ── */
.cv-node-resize {
    position: absolute; bottom: 0; right: 0;
    width: 16px; height: 16px; cursor: nwse-resize;
}

.cv-node-resize::after {
    content: '';
    position: absolute; bottom: 4px; right: 4px;
    width: 8px; height: 8px;
    border-right: 2px solid var(--n-200);
    border-bottom: 2px solid var(--n-200);
    border-radius: 0 0 2px 0;
}

/* ── Sticky note ── */
.cv-node.sticky {
    border-radius: 10px;
    box-shadow: 0 2px 6px var(--b07);
}

.cv-node.sticky .cv-node-head { padding: 8px 10px; }

.cv-sticky-body {
    flex: 1; padding: 10px 12px;
    user-select: text;
}

.cv-sticky-body textarea {
    width: 100%; height: 100%; border: none; outline: none;
    font: 400 13px/1.6 var(--font-sans);
    color: var(--n-700); background: transparent;
    resize: none;
}

.cv-node.sticky.yellow { background: #fefce8; border-color: #fde047; }
.cv-node.sticky.yellow .cv-node-head { background: #fef9c3; border-color: #fde047; }
.cv-node.sticky.blue { background: var(--a-50); border-color: var(--a-200); }
.cv-node.sticky.blue .cv-node-head { background: var(--a-100); border-color: var(--a-200); }
.cv-node.sticky.green { background: var(--green-bg); border-color: #86efac; }
.cv-node.sticky.green .cv-node-head { background: #dcfce7; border-color: #86efac; }
.cv-node.sticky.pink { background: #fdf2f8; border-color: #f9a8d4; }
.cv-node.sticky.pink .cv-node-head { background: #fce7f3; border-color: #f9a8d4; }

/* ── Terminal node ── */
.cv-node.terminal {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    color: #d4d4d4;
    font-family: Menlo, Monaco, "Courier New", monospace;
}

.cv-node.terminal .cv-node-head {
    background: #252526;
    border-bottom: 1px solid #333;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cv-node.terminal .cv-node-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cv-node.terminal.status-idle .cv-node-status-indicator {
    background: #858585;
}

.cv-node.terminal.status-running .cv-node-status-indicator {
    background: #4ec9b0;
    animation: statusPulse 1.5s ease-in-out infinite;
}

.cv-node.terminal.status-error .cv-node-status-indicator {
    background: #f14c4c;
}

.cv-node.terminal .cv-node-title {
    font-size: 12px;
    font-weight: 500;
    color: #cccccc;
}

.cv-term-toolbar {
    display: flex;
    gap: 4px;
}

.cv-term-toolbar .cv-node-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: #3c3c3c;
    border: none;
    color: #cccccc;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all var(--fast) ease;
}

.cv-term-toolbar .cv-node-btn:hover {
    background: #4a4a4a;
    color: #ffffff;
}

.cv-term-toolbar .cv-node-btn svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cv-term-content {
    flex: 1;
    padding: 0;
    overflow: hidden;
    background: #1e1e1e;
}

.cv-term-content .xterm {
    width: 100%;
    height: 100%;
}

.cv-term-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #f14c4c;
    font-size: 13px;
}

.cv-term-error svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}

/* ════════ SVG LAYERS ════════ */
.cv-edges-layer, .cv-drawings-layer {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: visible;
}

.cv-edges-layer path {
    fill: none; stroke: var(--n-300); stroke-width: 2;
    pointer-events: stroke;
    cursor: pointer;
}

.cv-edges-layer path:hover { stroke: var(--a-500); stroke-width: 2.5; }
.cv-edges-layer path.delegation { stroke: var(--a-500); stroke-dasharray: 6 3; }
.cv-edges-layer path.data_flow { stroke: var(--green); }
.cv-edges-layer path.reference { stroke: var(--n-300); stroke-dasharray: 4 4; }

.cv-drawings-layer path { pointer-events: stroke; cursor: pointer; }
.cv-drawings-layer path:hover { opacity: 0.6; }

/* ════════ EDGE CREATION PREVIEW ════════ */
.cv-edge-preview {
    fill: none; stroke: var(--a-400); stroke-width: 2;
    stroke-dasharray: 6 4; pointer-events: none;
}

/* ════════ COLLABORATION ════════ */
.cv-peer-cursor {
    position: absolute; pointer-events: none; z-index: 50;
    transition: left 80ms linear, top 80ms linear;
}
.cv-peer-cursor svg { width: 16px; height: 16px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }
.cv-peer-label {
    position: absolute; left: 16px; top: 12px;
    padding: 2px 7px; border-radius: 4px;
    font: 600 10px var(--font-sans); color: #fff;
    white-space: nowrap;
}

.cv-peers-badge {
    position: absolute; top: 52px; right: 16px; z-index: 10;
    display: flex; align-items: center; gap: -4px;
    padding: 4px 8px; background: var(--n-0);
    border: 1px solid var(--n-150); border-radius: 20px;
    box-shadow: 0 2px 8px var(--b07);
}
.cv-peers-badge:empty { display: none; }

.cv-peer-avatar {
    width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center;
    font: 700 10px var(--font-sans); color: #fff;
    border: 2px solid var(--n-0);
    margin-left: -6px;
}
.cv-peer-avatar:first-child { margin-left: 0; }

.cv-peers-count {
    font: 600 11px var(--font-sans); color: var(--n-500);
    margin-left: 4px;
}

/* ════════ SSH MODAL ════════ */
.cv-modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0,0,0,0.35); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
}

.cv-modal {
    background: var(--n-0); border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 420px; max-height: 70vh;
    display: flex; flex-direction: column;
    overflow: hidden;
}

.cv-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--n-100);
    font: 600 14px var(--font-sans); color: var(--n-800);
}

.cv-modal-close {
    width: 28px; height: 28px; border-radius: 6px;
    border: none; background: transparent; color: var(--n-400);
    font-size: 20px; cursor: pointer; display: grid; place-items: center;
    transition: all var(--fast) ease;
}
.cv-modal-close:hover { background: var(--b05); color: var(--n-700); }

.cv-modal-body { padding: 8px; overflow-y: auto; }

.cv-ssh-list { display: flex; flex-direction: column; gap: 2px; }

.cv-ssh-loading, .cv-ssh-empty {
    padding: 32px 20px; text-align: center;
    font: 400 13px var(--font-sans); color: var(--n-400);
}

.cv-ssh-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-radius: 8px;
    cursor: pointer; transition: all var(--fast) ease;
}
.cv-ssh-item:hover { background: var(--a-50); }

.cv-ssh-item-info { display: flex; flex-direction: column; gap: 2px; }

.cv-ssh-name { font: 500 13px var(--font-sans); color: var(--n-800); }
.cv-ssh-host { font: 400 11px var(--font-mono); color: var(--n-400); }

.cv-ssh-item svg {
    width: 16px; height: 16px; stroke: var(--n-300); fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    flex-shrink: 0;
}
.cv-ssh-item:hover svg { stroke: var(--a-500); }

/* ════════ TOAST ════════ */
.cv-toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    padding: 8px 18px; border-radius: 8px;
    background: var(--n-800); color: var(--n-0);
    font: 500 13px var(--font-sans);
    box-shadow: 0 4px 20px var(--b20);
    z-index: 200; pointer-events: none;
    animation: toastIn .25s var(--ease), toastOut .25s var(--ease) 2s forwards;
}

@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* ════════ MOBILE OVERLAY ════════ */
.cv-sb-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); z-index: 15;
}

.cv-sb-overlay.on { display: block; }

.cv-mobile-toggle {
    display: none; position: absolute; top: 50px; left: 12px; z-index: 10;
    width: 36px; height: 36px; border-radius: 9px;
    border: 1px solid var(--n-150); background: var(--n-0);
    color: var(--n-500); cursor: pointer;
    place-items: center; box-shadow: 0 1px 4px var(--b07);
}

.cv-mobile-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }

@media (max-width: 768px) {
    .cv-sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%); z-index: 30; width: 260px;
    }
    .cv-sidebar.open { transform: translateX(0); }
    .cv-mobile-toggle { display: grid; }
    .cv-toolbar { left: auto; right: 12px; transform: none; }
}
