:root {
    /* ========== TYPOGRAPHY ========== */
    --font-main: system-ui, -apple-system, sans-serif;
    --font-code: ui-monospace, monospace;
    
    /* Font sizes */
    --text-xs: 10px;
    --text-sm: 12px;
    --text-base: 14px;
    --text-md: 16px;
    --text-lg: 20px;
    --text-xl: 48px;
    
    /* Font weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Line heights */
    --leading-tight: 1.2;
    --leading-normal: 1.4;  /* Main text line height */
    --leading-relaxed: 1.8;

 
     /* ========== GRID SYSTEM ========== */
    /* Base grid unit derived from text line height */
    --text-line-height: calc(var(--text-base) * var(--leading-normal)); /* 14px * 1.4 = 19.6px */
    --grid-base-unit: 24px; /* Slightly larger than one line for good spacing */

    /* ========== SPACING ========== */
    --space-xs: calc(var(--grid-base-unit) * 0.5);
    --space-sm: calc(var(--grid-base-unit) * 0.75);
    --space-md: var(--grid-base-unit); /* 24px - now grid-aligned */
    --space-lg: calc(var(--grid-base-unit) * 1.5); /* 36px */
    --space-xl: calc(var(--grid-base-unit) * 2); /* 48px */


    /* ========== COLORS ========== */
    /* Base colors - Light mode */
    --color-bw: #ffffff;
    --color-bg: #f5f5f5;
    --color-fg: #111111;
    --color-muted: #666666;
    --color-border: #e0e0e0;
    --color-accent: #0066cc;
    --color-danger: #dc2626;
    --color-grid: rgba(0,0,0, 0.2);
    
    /* Surface hierarchy - Light mode */
    --color-surface-1: #f5f5f5;  /* viewport bg */
    --color-surface-2: #eeeeee;  /* link item bg */
    --color-surface-3: #23241f;  /* code item bg - stays dark */
    --color-surface-4: #000000;  /* embed item bg - stays dark */
    
    /* Text hierarchy - Light mode */
    --color-text-primary: #111111;
    --color-text-secondary: #666666;
    --color-text-muted: #999999;
    
    /* Interactive states - Light mode */
    --color-hover: rgba(0, 0, 0, 0.05);
    --color-active: rgba(0, 0, 0, 0.1);
    --color-selected: rgba(0,0,0, 0.1);
    --color-multi-selected: rgba(0, 102, 204, 0.8);

    /* ========== LAYOUT ========== */
    /* Component sizes */
    --toolbar-height: 48px;
    --canvas-size: 5000px;
    --viewport-top: var(--toolbar-height);
    
    /* Item dimensions */
    --item-min-width: 50px;
    --item-min-height: 50px;
    --text-item-min-width: 200px;
    --code-item-min-width: 300px;
    --item-padding: var(--space-md);
    
    /* Interactive elements */
    --btn-height: 36px;
    --btn-padding-x: var(--space-md);
    --btn-padding-y: var(--space-sm);
    --toolbar-btn-size: 28px;
    --delete-btn-size: 20px;
    --resize-handle-size: 16px;
    
    /* ========== BORDERS & RADIUS ========== */
    --border-width: 1px;
    --border-style: solid;
    --border: var(--border-width) var(--border-style) var(--color-border);
    
    /* Border radius */
    --radius-sm: 3px;
    --radius-md: 6px;
    --radius-lg: 12px;
    --radius-item: 12px;
    --radius-full: 50%;
    
    /* ========== EFFECTS ========== */
    /* Opacity states */
    --opacity-hover: 1;
    --opacity-dragging: 0.8;
    --opacity-disabled: 0.5;
    --opacity-muted: 0.5;
    
    /* Z-index layers */
    --z-base: 1;
    --z-overlay: 2;
    --z-selected: 100;
    --z-dragging: 101;
    --z-toolbar: 1000;
    --z-dropdown: 1001;
    
    /* Transitions */
    --transition-fast: 0ms ease;
    --transition-normal: 0ms ease;
    
    /* Code editor colors - constant in both themes */
    --code-bg: #23241f;
    --code-text: #d4d4d4;
    --code-keyword: #569cd6;
    --code-string: #ce9178;
    --code-comment: #6a9955;
    --code-number: #b5cea8;
    --code-function: #dcdcaa;

      
    /* ========== LAYOUT ========== */
    
    /* Item dimensions - grid-aligned */
    --item-min-width: calc(var(--grid-base-unit) * 4); /* 96px */
    --item-min-height: calc(var(--grid-base-unit) * 2); /* 48px */
    --text-item-min-width: calc(var(--grid-base-unit) * 8); /* 192px */
    --code-item-min-width: calc(var(--grid-base-unit) * 12); /* 288px */
    --item-padding: calc(var(--grid-base-unit) * 0.75); /* 18px - close to 16px but grid-aligned */

    --color-bg-tertiary: rgba(255,255,255,0.05);
}


/* Dark mode - Perfectly inverted with same contrast ratios */
body.dark-theme {
    /* Inverted base colors */
    --color-bw: #000000;
    --color-bg: #111111;
    --color-fg: #ffffff;
    --color-muted: #999999;
    --color-border: #2a2a2a;
    --color-accent: #4d94ff;
    --color-danger: #ef4444;
    --color-grid: rgba(255,255,255, 0.1);
    
    /* Inverted surface hierarchy */
    --color-surface-1: #0a0a0a;
    --color-surface-2: #1a1a1a;
    /* --color-surface-3 and --color-surface-4 stay the same */
    
    /* Inverted text hierarchy */
    --color-text-primary: #ffffff;
    --color-text-secondary: #999999;
    --color-text-muted: #666666;
    
    /* Inverted interactive states */
    --color-hover: rgba(255, 255, 255, 0.05);
    --color-active: rgba(255, 255, 255, 0.1);
    --color-selected: rgba(255,255,255, 0.25);
    --color-multi-selected: rgba(77, 148, 255, 0.8);

    --border: var(--border-width) var(--border-style) var(--color-border);
}

/* ========== GLOBAL STYLES ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overscroll-behavior-x: none;
    overscroll-behavior-y: none;
    font: var(--text-base)/var(--leading-normal) var(--font-main);
    background: var(--color-bg);
    color: var(--color-fg);
    overflow: hidden;
    transition: background-color var(--transition-normal), 
                color var(--transition-normal);
}

/* ========== TOOLBAR ========== */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--toolbar-height);
    background: var(--color-bg);
    border-bottom: var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-md);
    gap: var(--space-sm);
    z-index: var(--z-toolbar);
    transition: background-color var(--transition-normal),
                border-color var(--transition-normal);
}

/* Toolbar buttons */
.tool-btn,
.tool-select {
    height: var(--btn-height);
    padding: var(--btn-padding-y) var(--btn-padding-x);
    background: transparent;
    color: var(--color-fg);
    border: var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font: inherit;
    transition: all var(--transition-fast);
}

.tool-btn:hover,
.tool-select:hover {
    background: var(--color-hover);
    border-color: var(--color-muted);
}

.tool-btn:active {
    background: var(--color-active);
}

.tool-btn.danger {
    color: var(--color-danger);
}

.tool-btn.danger:hover {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

/* Drawing mode styles */
.tool-btn.active {
    /*background: var(--color-accent);*/
    color:  var(--color-accent);
    
}

.line-item {
    pointer-events: none; /* Allow canvas interactions through line SVG */
    background: transparent !important; /* Force transparent background */
    border: none !important; /* Remove any inherited borders */
}

.line-selection-overlay {
    background: transparent;
    pointer-events: all;
    border-radius: var(--radius-md);
}

.line-item.selected .line-selection-overlay {
    /*background: rgba(0, 123, 255, 0.1);*/
    /*border: var(--border-width) solid var(--color-accent);*/
}

.line-item .delete-btn {
    pointer-events: all; /* Ensure delete button works */
}

/* Disable hover effects during drawing mode */
.drawing-mode-active .canvas-item:hover {
    transform: none !important;
    box-shadow: none !important;
    background: transparent !important;
    border-color: transparent !important;
}

/* Specifically disable hover border for line items during drawing mode */
.drawing-mode-active .canvas-item.line-item:hover:not(.section-container) {
    border-color: transparent !important;
}

.drawing-mode-active .delete-btn {
    opacity: 0 !important;
}

.drawing-mode-active .resize-handle {
    opacity: 0 !important;
}

/* Disable connection and port hover effects during drawing mode */
.drawing-mode-active .canvas-item:hover .connection-port,
.drawing-mode-active .section-container > .canvas-item:hover .connection-port,
.drawing-mode-active .logic-item:hover .connection-port {
    opacity: 0 !important;
}

.drawing-mode-active .connection-port:hover {
    opacity: 0 !important;
    transform: none !important;
}

.drawing-mode-active .connection-line:hover {
    stroke-width: inherit !important;
    opacity: inherit !important;
}

.drawing-mode-active .connection-port.port-hover-valid .port-dot,
.drawing-mode-active .connection-port.port-hover-invalid .port-dot {
    transform: none !important;
    background: inherit !important;
    box-shadow: none !important;
}

/* Drawing controls styling */
.drawing-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.opacity-slider {
    width: 80px;
    height: 20px;
    background: #ddd;
    outline: none;
    border-radius: 10px;
    -webkit-appearance: none;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
}

.opacity-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    border: none;
}

.opacity-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    min-width: 35px;
    text-align: center;
}

#themeToggle {
    width: var(--btn-height);
    /*padding: var(--btn-padding-y);*/
    font-size: 18px;
}

.zoom-level {
    margin-left: auto;
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
}

.tool-btn .item-counter {
    position: absolute;
    /*top: -8px;*/
    left: 19px;
    color: var(--color-danger);
   
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    display: none;
}

.tool-btn .item-counter:not(:empty) {
    display: block;
}

.tool-btn.danger {
    position: relative;
    width: auto;
    min-width: 32px;
}

/* ========== VIEWPORT & CANVAS ========== */
#viewport {
    position: fixed;
    top: var(--viewport-top);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-surface-1);
    cursor: grab;
    overflow: hidden;
    transition: background-color var(--transition-normal);
    overscroll-behavior: none;
    touch-action: none; /* This prevents all default touch behaviors */

}

#viewport.grabbing {
    cursor: grabbing;
}

#canvas {
    width: var(--canvas-size);
    height: var(--canvas-size);
    background: var(--color-bg);
    transform-origin: 0 0;
    position: relative;
    transition: background-color var(--transition-normal);
}

/* ========== CANVAS ITEMS - Base ========== */
.canvas-item {
    position: absolute;
    background: var(--color-bg);
    border: var(--border);
    border-radius: var(--radius-lg);
    padding: var(--item-padding);
    /*cursor: move;*/
    user-select: none;
    min-width: var(--item-min-width);
    min-height: var(--item-min-height);
    transition: border-color 0s,
                background-color var(--transition-normal);
    will-change: transform;
    transform: translateZ(0);
    border-width: calc(1px / var(--zoom-scale, 1));
}

/* Only apply hover styles to items on canvas, not when hovering section containers */
.canvas-item:hover:not(.section-container) {
    border-color: var(--color-text-secondary);
}

/* For section containers, only apply hover to direct children */
.section-container > .canvas-item:hover {
    border-color: var(--color-text-secondary);
}

/* Canvas item states */
.canvas-item.selected {
    border-color: var(--color-accent);
    /*background: var(--color-selected);*/
    z-index: var(--z-selected);
    border-width: calc(2px / var(--zoom-scale, 1));
}

/* Hide individual selection styling when unified selection is active */
.canvas-item.multi-selected {
    /* Remove individual selection styling for cleaner unified selection */
}

.canvas-item.dragging {
    opacity: var(--opacity-dragging);
    z-index: var(--z-dragging);
    transition: none;
}

.canvas-item.dragging,
.canvas-item.dragging * {
    transition: none !important;
}

.canvas-item.preparing-drag {
    animation: pulse 0.3s ease-in-out;
}

.canvas-item.drag-ready {
    opacity: var(--opacity-dragging);
}

/* Canvas item overlays */
.shift-hover-overlay,
.multi-select-overlay {
    position: absolute;
    inset: 0;
    z-index: var(--z-overlay);
    /*cursor: pointer;*/
    background: transparent;
}

.multi-select-overlay {
    /*cursor: move;*/
}

/* Image item specific multi-select */
.image-item.multi-selected {
    /*position: relative;*/
}

.image-item .multi-select-overlay {
    border-radius: var(--radius-lg); /* Match the image border radius */
    /*background: var(--color-selected);*/
}

/* Ensure overlay works with padding: 0 items */
.image-item .multi-select-overlay,
.embed-item .multi-select-overlay,
.link-item .multi-select-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-overlay);
}

body.shift-held .canvas-item:hover .shift-hover-overlay {
    pointer-events: all;
}



/* Disable interactivity when multi-selected */
.canvas-item.multi-selected iframe,
.canvas-item.multi-selected [contenteditable],
.canvas-item.multi-selected a,
.canvas-item.multi-selected .rich-text-editor,
.canvas-item.multi-selected .ql-editor {
    pointer-events: none !important;
    user-select: none;
}

/* Resize Handle */
.resize-handle {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: var(--resize-handle-size);
    height: var(--resize-handle-size);
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 1000000000000;
    transform: scale(calc(1 / var(--zoom-scale, 1)));
}

/* Only show resize handles when hovering direct items, not section containers */
.canvas-item:hover:not(.section-container) .resize-handle {
    opacity: var(--opacity-hover);
}

.section-container > .canvas-item:hover .resize-handle {
    opacity: var(--opacity-hover);
}

.resize-handle::before {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: calc(var(--resize-handle-size) / 2);
    height: calc(var(--resize-handle-size) / 2);
    border-right: 2px solid var(--color-text-secondary);
    border-bottom: 2px solid var(--color-text-secondary);
}

/* Delete Button */
.delete-btn {
    position: absolute;
    top: calc(var(--delete-btn-size) / -2);
    right: calc(var(--delete-btn-size) / -2);
    width: var(--delete-btn-size);
    height: var(--delete-btn-size);
    background: var(--color-bg);
    color: var(--color-accent);
    border: var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font: bold var(--text-xs)/1 var(--font-main);
    transition: all var(--transition-fast);
    transform: scale(calc(1 / var(--zoom-scale, 1)));
    z-index: 10000000000000;
}

/* Only show delete buttons when hovering direct items, not section containers */
.canvas-item:hover:not(.section-container) .delete-btn {
    display: flex;
}

.section-container > .canvas-item:hover .delete-btn {
    display: flex;
}
/* ========== TEXT ITEM ========== */
.text-item {
    min-width: var(--text-item-min-width);
    min-height: calc(var(--grid-base-unit) * 2); /* Exactly 2 grid units = 48px */
    width: calc(var(--grid-base-unit) * 12); /* 288px - grid-aligned default width */
    height: auto;/*calc(var(--grid-base-unit) * 2);*/
    /*padding: 12px !important; /* Adjusted padding for better grid fit */
    padding: var(--space-xs) var(--space-sm);
    transition: none;
    animation: none;
}



.rich-text-editor {
    width: 100%;
    height: 20px;
    border: none !important;
    outline: none !important;
    font: inherit;
    color: var(--color-fg);
    background: transparent;
    overflow-y: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
    cursor: text;
    padding: 0; /* Remove any padding from editor itself */
    margin: 0; /* Remove any margin from editor itself */
    line-height: 1.0 !important; /* Consistent line height */
    font-size: var(--text-base); /* Consistent font size */
    padding-right: var(--space-sm);
}

.rich-text-editor:empty:before {
    content: '...';
    color: var(--color-text-secondary);
    line-height: 1.0; /* Match editor line height */
}

.rich-text-editor ul { 
    margin: 0; /* Remove margins */
    padding-left: var(--space-lg); 
    line-height: 1.4; /* Match editor line height */
}

.rich-text-editor li {
    margin: 0; /* Remove margins */
    padding: 0; /* Remove padding */
    line-height: 1.4; /* Match editor line height */
}
.delete-btn:hover {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}


.text-item.text-style-h1,
.text-item.text-style-h2 {
    padding: 10px !important;
}

/* Text item style classes */
.text-item.text-style-h1 .rich-text-editor,
.text-item.text-style-h1 .rich-text-editor * {
    font-size: var(--text-xl) !important;
    /*font-weight: var(--font-bold) !important;*/
    line-height: 0.99 !important;
}

.text-item.text-style-h2 .rich-text-editor,
.text-item.text-style-h2 .rich-text-editor * {
    font-size: var(--text-lg) !important;
    /*font-weight: var(--font-semibold) !important;*/
    line-height: 1.2 !important;
}

.text-item.text-style-h3 .rich-text-editor,
.text-item.text-style-h3 .rich-text-editor * {
    font-size: var(--text-md) !important;
    /*font-weight: var(--font-semibold) !important;*/
    line-height: 1.2 !important;
}

.text-item.text-style-p .rich-text-editor,
.text-item.text-style-p .rich-text-editor * {
    font-size: var(--text-base) !important;
    /*font-weight: var(--font-normal) !important;*/
    line-height: 1.4 !important;
}


/* Checkboxes */
.checkbox-wrapper {
    display: flex;
    gap: var(--space-sm);
    /*margin: var(--space-xs) 0;*/
}

.checkbox-wrapper input {
    margin-top: 2px;
    accent-color: var(--color-accent);
}

.checkbox-wrapper.checked .checkbox-content {
    text-decoration: line-through;
    opacity: var(--opacity-muted);
}

/* ========== CODE ITEM ========== */
.code-item {
    background: var(--code-bg);
    padding: 0 !important;
    min-width: var(--code-item-min-width);
    min-height: 64px;
}

.quill-code-container {
    width: 100%;
    height: 100%;
}

.code-item .ql-container {
    font-family: var(--font-code);
    font-size: var(--text-sm);
    border: none;
    height: 100%;
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
}

.code-item .ql-editor {
    padding: 0;
    color: var(--code-text);
}

.code-item .ql-toolbar {
    display: none;
}

/* Quill specific */
.code-item .ql-clipboard,
.code-item .ql-tooltip {
    display: none !important;
}

.ql-snow .ql-editor pre,
.ql-snow .ql-editor pre.ql-syntax {
    padding: 0;
    background: transparent;
}

/* Syntax highlighting */
.code-item .hljs-keyword { color: var(--code-keyword); }
.code-item .hljs-string { color: var(--code-string); }
.code-item .hljs-comment { color: var(--code-comment); }
.code-item .hljs-number { color: var(--code-number); }
.code-item .hljs-function { color: var(--code-function); }

/* ========== IMAGE ITEM ========== */
.image-item {
    padding: 0 !important;
    background: transparent !important;
    border: 1px solid white;
}

.image-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-item);
}

/* ========== EMBED ITEM ========== */
.embed-item {
    padding: 0 !important;
    background: var(--color-surface-4);
}

.iframe-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-item);
    overflow: hidden;
}

.iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.drag-overlay {
    position: absolute;
    inset: 0;
    z-index: var(--z-base);
}

/* ========== LINK ITEM ========== */
.link-item {
    background: var(--color-surface-2);
    min-width: 280px;
    max-width: 400px;
    overflow: hidden;
}

/* Link item states */
.link-item.link-loading {
    padding: var(--space-lg) !important;
    min-height: 80px;
}

.link-item.link-simple {
    min-width: 300px;
}

/* ========== SIZE VARIANTS ========== */
/* Small size - Compact single line */
.link-item.link-small {
    min-width: 200px;
    max-width: 400px;
    min-height: 60px;
    height: 60px !important;
    max-height: 60px !important;
}

/* Medium size - Standard with side image */
.link-item.link-medium {
    min-width: 300px;
    max-width: 400px;
    min-height: 100px;
    max-height: 140px !important;
}

/* Large size - Card with top image */
.link-item.link-large {
    min-width: 350px;
    max-width: 400px;
    min-height: 200px;
    max-height: 900px !important;
}

/* ========== LINK WRAPPER ========== */
.link-wrapper {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    width: 100%;
    height: 100%;
}

.link-wrapper.no-image {
    padding: 0;
}

.link-wrapper.with-image {
    padding: 0;
}

/* ========== LAYOUT VARIATIONS ========== */
/* Small layout */
.link-small .link-wrapper {
    /*padding: var(--space-sm) var(--space-md);*/
}

.link-small .link-image {
    display: none;
}

.link-small .link-description {
    display: none;
}

.link-small .link-details {
    flex-direction: row;
    align-items: center;
    gap: var(--space-sm);
    padding-top: 0;
}

.link-small .link-header {
    margin: 0;
}

.link-small .link-title {
    font-size: var(--text-sm);
    -webkit-line-clamp: 1;
}

/* Medium layout */
.link-medium .link-wrapper {
    padding: 0;
}

.link-medium .link-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    overflow: hidden;
    background: var(--color-surface-1);
    order: 2;
}

.link-medium .link-title {
    padding-right: 20px;
}

.link-medium .link-details {
    order: 1;
    padding-top: 0;
}

.link-medium .link-description {
    display: none;
}

/* Large layout */
.link-large .link-wrapper {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
}

.link-large .link-image {
    width: 100%;
    height: auto; /* Changed from fixed 180px to auto */
    order: 1;
    flex-shrink: 0;
    display: flex; /* Add flex to contain the image properly */
    justify-content: center;
    background: var(--color-surface-1);
}

.link-large .link-details {
    /*padding: var(--space-md);*/
    order: 2;
}

.link-large .link-title {
    font-size: var(--text-md);
    -webkit-line-clamp: 2;
}

.link-large .link-description {
    -webkit-line-clamp: 3;
}

.link-large .link-image img {
    width: 100%;
    height: auto; /* Let height be determined by aspect ratio */
    object-fit: contain; /* Changed from cover to contain to show full image */
    display: block;
    border-radius: var(--radius-md);
    overflow: hidden;
    /*max-height: 300px; /* Optional: set a max height to prevent extremely tall images */*/
}

/* ========== LINK IMAGE ========== */
.link-image {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    overflow: hidden;
    background: var(--color-surface-1);
}

.link-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ========== LINK DETAILS ========== */
.link-details {
    flex: 1;
    padding-top: var(--space-md);
    
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    min-width: 0;
}

.link-wrapper.no-image .link-details {
    padding: 0;
}

/* ========== LINK HEADER ========== */
.link-header {
    display: flex;
    align-items: center;
    gap: calc(var(--space-xs) * 0.5);
    margin-bottom: calc(var(--space-xs) * 0.5);
}

.link-favicon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    flex-shrink: 0;
}

.link-domain {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== LINK CONTENT ========== */
.link-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--color-fg);
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-description {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: 1.4;
    margin: var(--space-xs) 0 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-url {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin: var(--space-xs) 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== LINK ICON (Fallback) ========== */
.link-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    margin-right: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-favicon-large {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.link-icon-fallback {
    width: 48px;
    height: 48px;
    background: var(--color-surface-1);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

/* ========== LOADING STATE ========== */
.link-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: var(--space-sm);
}

.link-loading-text {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}

/* ========== DRAG PREVENTION ========== */
.link-item,
.link-item *,
.link-wrapper,
.link-wrapper *,
.link-title,
.link-description,
.link-domain,
.link-url {
    -webkit-user-drag: none;
    user-drag: none;
}

.link-title,
.link-description,
.link-domain,
.link-url {
    user-select: text;
}

/* ========== SELECTION BOX ========== */
.selection-box {
    position: absolute;
    border: 2px solid var(--color-accent);
    background: var(--color-selected);
    opacity: 0.3;
    pointer-events: none;
    z-index: var(--z-toolbar);
    border-radius: var(--radius-sm);
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary);
}

/* ========== ANIMATIONS ========== */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== FOCUS STATES ========== */
:focus-visible {
    outline: 0px solid var(--color-accent);
    outline-offset: 0px;
}

/* ========== VIDEO ITEM ========== */
.video-item {
    padding: 0 !important;
    background: var(--color-surface-4);
    min-width: 200px;
    min-height: 150px;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
}

.video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
}

.video-wrapper .drag-overlay {
    position: absolute;
    inset: 0;
    z-index: var(--z-base);
    /*cursor: move;*/
}

/* Hide overlay when not dragging to allow video controls */
.video-item:not(.dragging) .drag-overlay {
    pointer-events: none;
}

/* Show overlay on hover for drag indication */
.video-item.preparing-drag .drag-overlay,
.video-item.drag-ready .drag-overlay,
.video-item.dragging .drag-overlay {
    pointer-events: all;
}


/* ========== SECTION CONTAINER ========== */
.section-container {
    position: absolute;
    background: var(--color-surface-1);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    min-width: 200px;
    min-height: 150px;
    transition: all var(--transition-fast);
    overflow: visible;
}

.section-container:hover {
    border-color: var(--color-text-secondary);
    background: var(--color-hover);
}

.section-container.selected {
    border-style: solid;
    border-color: var(--color-accent);
    /*background: var(--color-selected);*/
}

.section-container.drag-over {
    border-color: var(--color-accent);
    /*background: var(--color-selected);*/
    border-width: 3px;
}

.section-container .section-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--space-lg);
    /*cursor: move;*/
    display: flex;
    align-items: center;
    padding: 0 var(--space-sm);
}

/* Ensure proper stacking */
.section-container {
    z-index: 0; /* Sections stay behind items by default */
}

.section-container.selected {
    z-index: 1; /* Selected sections come forward slightly */
}

/* Items inside sections - use auto to avoid creating new stacking context */
.section-container .canvas-item {
    z-index: auto;
}

.section-container .section-title {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    font-weight: var(--font-medium);
    opacity: 1;
    transition: opacity var(--transition-fast);
    cursor: text;
    /*padding: 2px 6px;*/
    border-radius: var(--radius-sm);
    min-width: 60px;
    white-space: nowrap;
}

.section-container .section-title.editing {
    opacity: 1;
    background: var(--color-bg);
    border: 1px solid var(--color-accent);
    outline: none;
    color: var(--color-fg);
}

.section-container:hover .section-title,
.section-container.selected .section-title {
    opacity: 1;
}

/* Section controls */
.section-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.section-container:hover .section-controls,
.section-container.selected .section-controls {
    opacity: 1;
}

.section-color-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.section-color-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.section-color-btn svg {
    color: #666;
}

.section-color-btn:hover svg {
    color: #333;
}

.section-share-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.section-share-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.section-share-btn svg {
    color: #666;
}

.section-share-btn:hover svg {
    color: #333;
}

/* ========== MISC ========== */
.hidden {
    display: none !important;
}

/* Disable transitions during grid operations */
.canvas-item.grid-snapping {
    transition: none !important;
}

.canvas-item.grid-snapping * {
    transition: none !important;
}

.viewport.drag-over {
    background-color: rgba(0, 123, 255, 0.05);
    border: 2px dashed #007bff;
}

.viewport.drag-over::after {
    content: 'Drop here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #007bff;
    pointer-events: none;
}

.section-container:hover .canvas-item .delete-btn,
.section-container:hover .canvas-item .resize-handle {
    display: none;
}

/* But show them when hovering the items directly */
.section-container .canvas-item:hover > .delete-btn,
.section-container .canvas-item:hover > .resize-handle {
    display: flex;
}

/* Embed active state */
.embed-item.embed-active .drag-overlay,
.video-item.embed-active .drag-overlay {
    background: transparent !important;
    pointer-events: none !important;
    cursor: default !important;
}

.embed-item.embed-active,
.video-item.embed-active {
    box-shadow: 0 0 0 3px var(--color-accent);
}

/* Show a subtle indicator when hovering inactive overlay */
.embed-item:not(.embed-active) .drag-overlay:hover,
.video-item:not(.embed-active) .drag-overlay:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Dark theme version */
body.dark-theme .embed-item:not(.embed-active) .drag-overlay:hover,
body.dark-theme .video-item:not(.embed-active) .drag-overlay:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Ensure overlays are always visible when not active */
.embed-item:not(.embed-active) .drag-overlay,
.video-item:not(.embed-active) .drag-overlay {
    pointer-events: all !important;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-bg-modal);
    color: var(--color-fg);
    padding: var(--space-xs);
    border-radius: var(--radius-lg);
    border: var(--border);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Modal overlay */
.toast-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.toast-overlay.show {
    opacity: 1;
    pointer-events: all;
}

/* Modal-style toast */
.toast-notification.modal {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%) scale(0.9);
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.toast-notification.modal.show {
    transform: translate(-50%, -50%) scale(1);
}

/* Keep your existing button styles... */
.toast-notification.has-buttons {
    padding: 16px 20px;
    max-width: 400px;
}

.toast-message {
    /*margin-bottom: 12px;*/
}

.toast-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    font-weight: bold;
}

.toast-button {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.toast-button:hover {
    background: rgba(255, 255, 255, 0.3);
    opacity: 0.5;
}

.toast-button.primary {
    background: white;
    color: #333;
}

.toast-button.primary:hover {
    background: rgba(255, 255, 255, 0.9);
}

body.dark-theme .toast-notification {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

body.dark-theme .toast-overlay {
    background: rgba(0, 0, 0, 0.7);
}


/* Board Switcher */
.board-switcher {
    display: flex;
    align-items: center;
    gap: var(--space-xs);

}

.board-switcher .tool-select {
    min-width: 50px;
    max-width: 250px;
    border-radius: var(--radius-md);
}

.board-switcher .tool-btn {
    padding: var(--space-xs);
    width: 32px;
    height: 32px;
}

/* Storage Indicator */
.storage-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-right: var(--space-md);
}

.storage-bar {
    width: 100px;
    height: 6px;
    background: var(--color-surface-2);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.storage-fill {
    height: 100%;
    background: var(--color-accent);
    transition: width 0.3s ease, background-color 0.3s ease;
}

.storage-text {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    white-space: nowrap;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .board-switcher .tool-select {
        min-width: 100px;
    }
    
    .storage-indicator {
        display: none;
    }
}

/* Custom ChatGPT-style Tooltips */
.custom-tooltip {
    position: fixed;
    background: #2f2f2f;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: var(--text-sm);
    font-weight: 400;
    white-space: nowrap;
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.custom-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

/* Dark theme tooltip (lighter background) */
body.dark-theme .custom-tooltip {
    background: #555;
}

/* Ghost copy preview */
/* Ghost copy preview */
.ghost-copy {
    opacity: 0.7 !important;
    pointer-events: none !important;
    border: 2px dashed var(--color-accent) !important;
    background: rgba(0, 102, 204, 0.05) !important;
}

.ghost-copy * {
    pointer-events: none !important;
}

/* Hide all interactive elements in ghosts */
.ghost-copy .delete-btn,
.ghost-copy .resize-handle,
.ghost-copy .link-toggle,
.ghost-copy button {
    display: none !important;
    visibility: hidden !important;
}

/* Long press visual feedback */
.long-press-ripple {
    position: fixed;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--color-accent);
    opacity: 0.2;
    pointer-events: none;
    z-index: 10000;
    animation: ripple 0.5s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 0.4;
    }
    100% {
        transform: scale(1);
        opacity: 0.2;
    }
}

/* Position indicators */
.position-indicators {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 999;
}

.position-indicator {
    position: absolute;
    background: rgba(0, 0, 0, 0.0);
    transition: opacity 0.2s ease;
}

body.dark-theme .position-indicator {
    background: rgba(255, 255, 255, 0.0);
}

/* Horizontal indicator (bottom) */
.position-indicator.horizontal {
    bottom: 6px;
    left: 6px;
    right: 6px;
    height: 2px;
    border-radius: 2px;
}

/* Vertical indicator (right side) */
.position-indicator.vertical {
    right: 6px;
    top: 6px; /* Account for toolbar */
    bottom: 6px;
    width: 2px;
    border-radius: 2px;
}

/* The moving dot */
.position-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--color-fg);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: opacity 0.1s ease-out;
    opacity: 0;
}

/* Position dot in center of track */
.horizontal .position-dot {
    top: 50%;
    transform: translateY(-50%);
}

.vertical .position-dot {
    left: 50%;
    transform: translateX(-50%);
}

/* Hide when zoomed out too far */
.position-dot {
    
}

.position-dot.hidden {
    opacity: 0;
}


body.canvas-panning .position-dot {
    opacity: 0.2;
}



/* API Settings Modal */
.api-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0s ease;
}

.api-settings-content {
    background: var(--color-bg);
    /*border: 1px solid rgba(255, 255, 255, 0.1);*/
    border-radius: var(--radius-lg);
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.2s ease;
}

/* Light mode */
body:not(.dark-theme) .api-settings-content {
    background: #ffffff;
    border: px solid rgba(0, 0, 0, 0.1);
}

/* Header */
.api-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    /*border-bottom: 1px solid rgba(255, 255, 255, 0.1);*/
}

body:not(.dark-theme) .api-settings-header {
    /*border-bottom: 1px solid rgba(0, 0, 0, 0.1);*/
}

.api-settings-header h2 {
    margin: 0;
    color: #ffffff;
}

body:not(.dark-theme) .api-settings-header h2 {
    color: #000000;
}

.api-close-btn {
    background: none;
    border: none;
    color: #959595;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: none;
}

.api-close-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

body:not(.dark-theme) .api-close-btn:hover {
    color: #000000;
    background: rgba(0, 0, 0, 0.05);
}

/* Body */
.api-settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Setting Row */
.api-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body:not(.dark-theme) .api-setting-row {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.api-setting-row:last-child {
    border-bottom: none;
}

.api-setting-info {
    flex: 1;
    margin-right: 24px;
}

.api-setting-label {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 4px;
}

body:not(.dark-theme) .api-setting-label {
    color: #000000;
}

.api-setting-description {
    font-size: var(--text-sm);
    color: #959595;
    line-height: 1.5;
}

/* API Key Input Group */
.api-setting-control {
    width: 300px;
}

.api-key-wrapper {
    position: relative;
    width: 100%;
}

.api-key-input {
    width: 100%;
    padding: 8px 40px 8px 12px;
    background: var(--color-surface-2);
    border: 0px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #ffffff;
    font-family: monospace;
    font-size: var(--text-sm);
    transition: all 0.2s ease;
}

body:not(.dark-theme) .api-key-input {
    /*background: var(--color-fg);*/
    border: 0px solid rgba(0, 0, 0, 0.1);
    color: #000000;
}

.api-key-input:focus {
    outline: none;
    border-color: #0066cc;
}

.api-key-input::placeholder {
    color: #666666;
}

.api-key-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #959595;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.api-key-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

body:not(.dark-theme) .api-key-toggle:hover {
    color: #000000;
    background: rgba(0, 0, 0, 0.05);
}

.api-key-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--color-accent);
    text-decoration: none;
}

.api-key-link:hover {
    text-decoration: underline;
}

/* Footer */
.api-settings-footer {
    padding: 20px 24px;
    /*border-top: 0px solid rgba(255, 255, 255, 0.1);*/
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

body:not(.dark-theme) .api-settings-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Buttons */
.api-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.api-btn.secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

body:not(.dark-theme) .api-btn.secondary {
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: #000000;
}

.api-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

body:not(.dark-theme) .api-btn.secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

.api-btn.primary {
    background: var(--color-accent);
    color: white;
    border: none;
}

.api-btn.primary:hover {
    opacity: 0.5;
}

/* Warning Box */
.api-settings-note {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 193, 7, 0.1);
    /*border: 1px solid rgba(255, 193, 7, 0.2);*/
    border-radius: 6px;
    margin: 0 0 24px 0;
    font-size: var(--text-sm);
    color: #ffc107;
}

body:not(.dark-theme) .api-settings-note {
    background: rgba(255, 193, 7, 0.05);
    color: #f57c00;
}

.api-settings-note svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Result Messages */
.api-test-result {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: var(--text-sm);
    display: none;
    align-items: center;
    gap: 8px;
}

.api-test-result.success {
    background: rgba(52, 211, 153, 0.1);
    color: #34d399;
}

.api-test-result.error {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
}

/* Scrollbar */
.api-settings-body::-webkit-scrollbar {
    width: 8px;
}

.api-settings-body::-webkit-scrollbar-track {
    background: transparent;
}

.api-settings-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.api-settings-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}









/* ========== INSTRUCTION ITEM - MINIMAL CHAT STYLE ========== */
.instruction-item {
    border: none !important;
    background: rgba(0, 0, 0, 0.08) !important;
    min-width: 280px;
    /*min-height: auto;*/
    padding: 0 !important;
    /*border-radius: 24px !important;*/
    box-shadow: none;
}

.instruction-item.selected, .instruction-item.multi-selected {
    border: 1px solid rgba(0,0,0, 0.2) !important;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.08) !important;
}

body.dark-theme .instruction-item {
    background: rgba(255, 255, 255, 0.08) !important;
}

body.dark-theme .instruction-item.selected, .instruction-item.multi-selected {
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.instruction-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    /*padding: 16px 20px 14px 20px;*/
    padding: var(--space-sm);
    justify-content: space-between;
    /*gap: 12px;*/
}

.instruction-input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: var(--font-main);
    font-size: var(--text-base);
    color: var(--color-fg);
    resize: none;
    outline: none;
    padding: 0;
    margin: 0;
    min-height: 24px;
    line-height: 1.5;
}

.instruction-input::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.6;
}

.instruction-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: 4px;
    padding-bottom: 0px;
    position: relative;
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    opacity:1;
}

.model-selector:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
}

body.dark-theme .model-selector:hover {
    background: rgba(255, 255, 255, 0.05);
}

.model-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.model-icon {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 4px;
    font-size: 9px;
}

.model-icon.claude {
    background: #D97706;
    color: white;
}

.model-icon.openai {
    background: #10B981;
    color: white;
}

.model-icon.gemini {
    background: #4285F4;
    color: white;
}

.model-icon.local {
    background: #8B5CF6;
    color: white;
}

.model-dropdown {
    position: absolute;
    bottom: 100%;
    left: -10px;
    margin-bottom: 4px;
    background: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 4px;
    min-width: 120px;
    display: none;
    transform: translateY(10px);
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

body.dark-theme .model-dropdown {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /*background: #eee;*/
}

.model-dropdown.show {
    display: block;
}

.model-option {
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s ease;
    color: #aaa;
}

.model-option:hover {
    background: var(--color-hover);
}

.model-option.selected {
    color: #7C3AED;
    font-weight: 500;
}

.instruction-run-btn {
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.1);
    color: var(--color-fg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

body.dark-theme .instruction-run-btn {
    background: rgba(255, 255, 255, 0.1);
}

.instruction-run-btn:hover {
    background: rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

body.dark-theme .instruction-run-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.instruction-run-btn:active {
    transform: scale(0.95);
}

.instruction-run-btn svg {
    width: 18px;
    height: 18px;
    margin-left: 2px;
}

.instruction-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.instruction-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(124, 58, 237, 0.2);
    border-top-color: #7C3AED;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.instruction-item.instruction-processing {
    background: rgba(124, 58, 237, 0.1) !important;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.3);
}

.instruction-item.pending-execution {
    animation: pendingGlow 0.6s ease-out;
    background: rgba(16, 185, 129, 0.1) !important;
}

@keyframes pendingGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(16, 185, 129, 0);
        transform: scale(1.02);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
        transform: scale(1);
    }
}

.instruction-context-indicator {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 16px;
    height: 16px;
    background: #3B82F6;
    border: 2px solid var(--color-bg);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    font-weight: bold;
}

.instruction-item.has-context .instruction-context-indicator {
    display: flex;
}

.instruction-error {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #EF4444;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 8px;
    animation: slideUp 0.3s ease-out;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== CONNECTION PORTS ========== */
.connection-port {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
    transform: translateY(-50%) scale(calc(1 / var(--zoom-scale, 1)));
}

/* Only show connection ports when hovering direct items, not section containers */
.canvas-item:hover:not(.section-container) .connection-port {
    opacity: 0.7;
}

.section-container > .canvas-item:hover .connection-port {
    opacity: 0.7;
}

.connection-port:hover {
    opacity: 1 !important;
}

.input-port {
    left: -13px;
}

.output-port {
    right: -13px;
}

.port-dot {
    width: 20px;
    height: 20px;
    background: #7C3AED;
    border: 10px solid var(--color-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
}

.port-dot svg {
    color: black;
}

.dark-theme .port-dot svg {
    color: white
}

.dark-theme .port-dot {
    border: 10px solid var(--color-bg);
}

.output-port .port-dot {
    background: #3B82F6;
}

.port-dot span {
    color: white;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-port .port-dot span {
    display: none;
}

/*.connection-port.connecting .port-dot {
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.2);
}

.connection-port.port-hover-valid .port-dot {
    transform: scale(1.4);
    background: #10B981 !important;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.3);
}

.connection-port.port-hover-invalid .port-dot {
    transform: scale(0.8);
    background: #EF4444 !important;
    opacity: 0.5;
}*/



.connection-preview {
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

body:has(.connection-port.connecting) .canvas-item .connection-port {
    opacity: 1;
}

.instruction-item .input-port .port-dot {
    background: #7C3AED;
}

.instruction-item .output-port .port-dot {
    background: #10B981;
}

@keyframes pulse-port {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.connection-port.connecting .port-dot {
    animation: pulse-port 1s ease-in-out infinite;
}

/* ========== CONNECTIONS SVG ========== */
.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    /* Width and height are set dynamically in JS to match canvas */
    pointer-events: none;
    z-index: 999999998 !important;
}

.connection-line {
    pointer-events: stroke;
    cursor: pointer;
    transition: stroke-width 0.2s ease, opacity 0.2s ease;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: calc(2px / var(--zoom-scale, 1)); /* Maintains 2px visual thickness */

}

.connection-line:hover {
    stroke-width: 4;
    opacity: 1;
    stroke-width: calc(4px / var(--zoom-scale, 1));
}

.connection-line.delete-hover {
    stroke: #EF4444 !important;
    stroke-width: 4;
    stroke-width: calc(4px / var(--zoom-scale, 1));
}

@keyframes flow {
    0% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -30;
    }
}

.connection-line.active {
    stroke-dasharray: calc(5px / var(--zoom-scale, 1)) calc(10px / var(--zoom-scale, 1));
    animation: flow 1s linear infinite;
}

/* ========== CONNECTED ITEMS STYLING ========== */
.canvas-item[data-connection-type="source"] {
    border: 1px solid #ccc !important;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.canvas-item[data-connection-type="output"] {
    border: 1px solid var(--color-hover) !important; /* #10B981 */
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.canvas-item[data-connection-type="instruction"] {
    border: 1px solid transparent; !important;
    box-shadow: 0 0 0 10px rgba(124, 58, 237, 0.3);
}

/*body.dark-theme .canvas-item[data-connection-type="source"] {
    border-color: var(--color-hover) !important;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
}

body.dark-theme .canvas-item[data-connection-type="output"] {
    border-color: #34D399 !important;
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}

body.dark-theme .canvas-item[data-connection-type="instruction"] {
    border-color: #A78BFA !important;
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.3);
}
*/
@keyframes pulse-glow {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(var(--glow-color), 0.3);
    }
    50% { 
        box-shadow: 0 0 20px rgba(var(--glow-color), 0.5);
    }
}

.canvas-item[data-connection-type="source"] {
    --glow-color: 59, 130, 246;
    animation: pulse-glow 3s ease-in-out infinite;
}

.canvas-item[data-connection-type="output"] {
    --glow-color: 16, 185, 129;
    animation: pulse-glow 3s ease-in-out infinite;
}

.canvas-item[data-connection-type="instruction"] {
    --glow-color: 124, 58, 237;
    animation: pulse-glow 3s ease-in-out infinite;
}

.item-run-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: #7C3AED;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

/* Only show run buttons when hovering direct items, not section containers */
.canvas-item:hover:not(.section-container) .item-run-btn {
    display: flex;
}

.section-container > .canvas-item:hover .item-run-btn {
    display: flex;
}

.item-run-btn:hover {
    background: #6D28D9;
    transform: scale(1.1);
}

@keyframes updateFlash {
    0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4); }
    50% { box-shadow: 0 0 20px 10px rgba(124, 58, 237, 0); }
    100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0); }
}

.canvas-item.updated {
    animation: updateFlash 0.5s ease-out;
}


/* Image model dropdown */
/* Image Model Selector - matching model-selector style */


.image-model-selector {
    display: flex
;
    align-items: center;
    gap: 4px;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    
}

.image-model-button {
   /* display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: var(--text-sm);
    color: #999;
    background: transparent;*/
}

.image-model-selector:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.image-model-label {
    font-size: var(--text-sm);
    font-weight: 500;
}

.image-model-dropdown-menu {
    position: absolute;
    bottom: 100%;
    right: 50px;
    margin-bottom: 4px;
    background: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 4px;
    min-width: 120px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.image-model-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    /*transform: translateY(0);*/
}

.image-model-option {
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 12px;
    color: #999;
}

.image-model-option:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.image-model-option.selected {
    background: rgba(124, 58, 237, 0.2);
    color: #A78BFA;
}

/* Status feedback */
.instruction-status {
    padding: 6px 12px;
    font-size: 10px;
    margin: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #888;
    transition: all 0.2s;
    position: absolute;
    box-sizing: border-box;
    bottom: -44px;
    right: 0;
    left: 0;
}

.instruction-status.info {
    color: #64B5F6;
    background: rgba(33, 150, 243, 0.1);
}

.instruction-status.success {
    color: #81C784;
    background: rgba(76, 175, 80, 0.1);
}

.instruction-status.error {
    color: #E57373;
    background: rgba(244, 67, 54, 0.1);
}

/* Make sure resize handle is visible */
.instruction-item .resize-handle {
    opacity: 0;
    transition: opacity 0.2s;
}

.instruction-item:hover .resize-handle {
    opacity: 1;
}

/* ========== AI BADGE ========== */
.ai-generated-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #7C3AED;
    color: white;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: var(--font-semibold);
    animation: fadeIn 0.3s ease-out;
    z-index: 10;
}

.ai-generated-badge.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* ========== ERROR FLASH ========== */
.canvas-item.error-flash {
    animation: errorFlash 0.5s ease-in-out 2;
}

@keyframes errorFlash {
    0%, 100% { 
        border-color: #EF4444;
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    }
    50% { 
        border-color: #DC2626;
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    }
}

/* Add to instruction item CSS */
.instruction-item .resize-handle {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.instruction-item:hover .resize-handle {
    opacity: 0.5;
}

/* Ensure instruction container doesn't block resize handle */
.instruction-container {
    pointer-events: none;
}

.instruction-container * {
    pointer-events: auto;
}

/* ========== DRAWING CONTROLS CONTAINER ========== */
.drawing-tool-container {
    position: relative;
    display: inline-block;
}

.drawing-controls-container {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--color-bw);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    pointer-events: none;
    min-width: 200px;
}

.drawing-controls-container.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.drawing-controls-compact {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.tool-select-compact {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    min-width: 40px;
}

.tool-btn-compact {
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tool-btn-compact:hover {
    background: var(--color-hover);
    border-color: var(--color-accent);
}

.color-preview {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    background: #000000;
    border: 1px solid rgba(0,0,0,0.1);
}

.opacity-control-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
}

.opacity-slider-compact {
    -webkit-appearance: none;
    width: 60px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    outline: none;
}

.opacity-slider-compact::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
}

.opacity-slider-compact::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.opacity-label-compact {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    min-width: 24px;
    text-align: right;
}

/* Active flow animation for connections */
.connection-line.active-flow {
    stroke-dasharray: calc(10px / var(--zoom-scale, 1)) calc(5px / var(--zoom-scale, 1)) !important;
    animation: flowActive 0.5s linear infinite !important;
    filter: drop-shadow(0 0 calc(4px / var(--zoom-scale, 1)) currentColor);
}

@keyframes flowActive {
    0% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -15;
    }
}

/* More obvious execution pulse for items */
.instruction-item.instruction-processing {
    animation: processingPulse 0.8s ease-in-out infinite !important;
    background: rgba(124, 58, 237, 0.15) !important;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.4) !important;
}

@keyframes processingPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 30px rgba(124, 58, 237, 0.6);
    }
}

/* Output update animation */
.canvas-item.output-updating {
    animation: outputPulse 0.6s ease-out;
}

@keyframes outputPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}


/* Markdown-specific styles */
.markdown-code-block {
    background: var(--color-surface-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: var(--text-sm);
    line-height: 1.5;
    margin: 8px 0;
}

.markdown-inline-code {
    background: var(--color-surface-secondary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9em;
}

.markdown-quote {
    border-left: 3px solid var(--color-primary);
    padding-left: 16px;
    margin: 8px 0;
    color: var(--color-text-secondary);
    font-style: italic;
}

/* Better list styling in text items */
/*.rich-text-editor ul,
.rich-text-editor ol {
    margin: 8px 0;
    padding-left: 24px;
}

.rich-text-editor li {
    margin: 4px 0;
}

.rich-text-editor h1 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 12px 0 8px 0;
}

.rich-text-editor h2 {
    font-size: 1.3em;
    font-weight: 600;
    margin: 10px 0 6px 0;
}

.rich-text-editor h3 {
    font-size: 1.1em;
    font-weight: 600;
    margin: 8px 0 4px 0;
}*/


/* Grid overlay */



.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
    background-image: radial-gradient(
        circle at center,
        var(--color-grid) 0,
        var(--color-grid) calc(1.25px / var(--zoom-scale, 1)), /* Scales inversely */
        transparent calc(0.5px / var(--zoom-scale, 1)),
        transparent 100%
    );
    background-size: var(--grid-base-unit) var(--grid-base-unit); /* 24px x 24px */
    background-position: calc(var(--grid-base-unit) / -2) calc(var(--grid-base-unit) / -2); /* -12px -12px */
}

.grid-overlay.visible {
    opacity: 1;
}

/* Grid toggle button */
#toggleGrid {
    /*background: none;*/
    border: none;
    padding: 8px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    color: var(--color-fg);
}

#toggleGrid:hover {
    opacity: 1;
}

#toggleGrid.active {
    opacity: 1;
    color: var(--color-accent);
}







/* WEB ELEMENTS */

/* Web Element Item Styles */
.web-element-item {
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-width: 200px;
    min-height: 150px;
}

.web-element-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: white;
}

.web-element-iframe {
    background: white;
}

.web-element-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.web-element-item:hover .web-element-controls {
    opacity: 1;
}

.web-element-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    border: 0px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: rgba(0,0,0, 0.6);
}

.web-element-btn:hover {
    background: rgba(255,255,255, 0.6);
    color: black;
    border-color: var(--color-primary);
}

.dark-theme .web-element-btn {
    color: rgba(255,255,255, 0.6);
    background: rgba(0,0,0, 0.8);
}

/* Active state */
.web-element-item.web-element-active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-alpha);
}

/* Editor Modal */
.web-element-editor-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.web-element-editor-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.web-element-editor-content {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.web-element-editor-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.web-element-editor-header h3 {
    margin: 0;
    font-size: 18px;
}

.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.close-btn:hover {
    opacity: 1;
}

.web-element-editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-tabs {
    display: flex;
    gap: 0;
    padding: 0 20px;
    border-bottom: 1px solid var(--color-border);
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--color-text);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.editor-panels {
    flex: 1;
    position: relative;
    min-height: 0;
}

.editor-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 20px;
    display: none;
}

.editor-panel.active {
    display: block;
}

.code-editor {
    width: 100%;
    height: 100%;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: var(--text-sm);
    line-height: 1.5;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-background);
    resize: none;
}

.web-element-editor-footer {
    padding: 20px;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.save-btn, .cancel-btn {
    padding: 8px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.save-btn {
    background: var(--color-primary);
    color: white;
}

.save-btn:hover {
    background: var(--color-primary-dark);
}

.cancel-btn {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.cancel-btn:hover {
    background: var(--color-background);
}

/* Fullscreen View */
.web-element-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-background);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s;
}

.web-element-fullscreen.show {
    opacity: 1;
}

.fullscreen-header {
    padding: 16px;
    display: flex;
    justify-content: flex-end;
    position: fixed;
    top: 0;
    /*background: var(--color-surface);*/
    /*border-bottom: 1px solid var(--color-border);*/
}

.close-fullscreen-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 0px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: fixed;
    right: 20px;
}

.dark-theme .close-fullscreen-btn {
    background: rgba(255,255,255,0.2);
}

.close-fullscreen-btn:hover {
    background: var(--color-background);
}

.dark-theme .close-fullscreen-btn:hover {
    background: rgba(255,255,255,0.5);
}


.fullscreen-iframe {
    flex: 1;
    border: none;
    background: white;
}

/* Dark theme adjustments */
.dark-theme .web-element-container,
.dark-theme .web-element-iframe,
.dark-theme .fullscreen-iframe {
    background: #1a1a1a;
}




/* Conversation */
/* ========== CONVERSATIONAL INSTRUCTIONS - ULTRA MINIMAL ========== */
.instruction-item {
    transition: all 0s ease !important;
}

.instruction-item.conversation-mode {
    min-height: 400px;
}

/* Hide initial input when in conversation mode */
.instruction-item.conversation-mode .instruction-input {
    display: none;
}

/* Keep footer visible in conversation mode but hide some elements */
.instruction-item.conversation-mode .instruction-footer {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 0px solid rgba(0, 0, 0, 0.06);
}

/* Hide run button and loading in conversation mode */
/*.instruction-item.conversation-mode .instruction-run-btn,*/
.instruction-item.conversation-mode .instruction-loading {
    display: none !important;
}

/* Show conversation toggle */
.instruction-item.has-output .conversation-toggle,
.instruction-item.conversation-mode .conversation-toggle {
    display: flex !important;
}

.conversation-view {
    display: none;
    flex-direction: column;
    height: 100%;
    min-height: 200px;
    padding: 0;
}

.instruction-item.conversation-mode .conversation-view {
    display: flex;
}

.conversation-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: transparent;
    margin-bottom: 8px;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}

/* Ultra minimal speech bubbles */
.conversation-message {
    padding: 8px 12px;
    border-radius: 16px;
    font-size: var(--text-base);
    line-height: 1.5;
    font-family: var(--font-sans);
    color: var(--color-fg);
    max-width: 80%;
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

.conversation-message.user {
    align-self: flex-end;
    background: rgba(0, 0, 0, 0.04);
    margin-left: 20%;
}

.conversation-message.assistant {
    align-self: flex-start;
    background: rgba(124, 58, 237, 0.08);
    margin-right: 20%;
}

body.dark-theme .conversation-message.user {
    background: rgba(255, 255, 255, 0.06);
}

body.dark-theme .conversation-message.assistant {
    background: rgba(0, 0, 0, 0.2);
}

.conversation-message.assistant.clarification {
    background: rgba(255, 193, 7, 0.08);
}

/* Single input area at bottom - minimal style */
.conversation-input-footer {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    padding: 0;
}

.conversation-input {
    flex: 1;
    min-height: 32px;
    max-height: 80px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    resize: none;
    outline: none;
    color: var(--color-fg);
    transition: all 0 ease;
}

body.dark-theme .conversation-input {
    background: rgba(255, 255, 255, 0.04);
}

.conversation-input:focus {
    background: rgba(0, 0, 0, 0.04);
}

body.dark-theme .conversation-input:focus {
    background: rgba(255, 255, 255, 0.1);
}

/* Minimal send button */

.conversation-input-footer .instruction-run-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 16px;
    opacity: 0.6;
    transition: all 0s ease;
}

.conversation-input-footer .instruction-run-btn:hover {
    opacity: 1;
    background: rgba(124, 58, 237, 0.08);
}

/* Output history indicator - more subtle */
.output-history-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 10px;
    color: var(--color-text-secondary);
    opacity: 0.4;
    display: none;
}

.instruction-item.has-history .output-history-indicator {
    display: block;
}

.output-history-nav {
    display: flex;
    gap: 2px;
    align-items: center;
}

.history-btn {
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--color-text-secondary);
    opacity: 0.6;
}

.history-btn:hover:not(:disabled) {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

.history-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

/* System messages - very subtle */
.conversation-message.system {
    align-self: center;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 11px;
    opacity: 0.5;
    margin: 0;
    padding: 4px 8px;
    max-width: none;
}

/* Conversation input port - keep the same */
.conversation-input-port {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: #F59E0B;
    border: 2px solid var(--color-bg);
    border-radius: 50%;
    cursor: crosshair;
    z-index: 10;
    opacity: 0;
    transition: all 0s ease;
    top: auto;
}

.conversation-mode .conversation-input-port {
    opacity: 1;
}

/* Animation for conversation flow */
.conversation-connection {
    stroke: #F59E0B !important;
    stroke-dasharray: 5, 3;
    animation: conversation-flow 1s linear infinite;
}

@keyframes conversation-flow {
    to {
        stroke-dashoffset: -8;
    }
}

/* Piped input flash effect - more subtle */
@keyframes piped-flash {
    0%, 100% { 
        background: rgba(0, 0, 0, 0.02);
    }
    50% { 
        background: rgba(245, 158, 11, 0.08);
    }
}

.instruction-footer-actions {
    display: flex;
    gap: 5px;
}
.conversation-toggle.btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 16px;
    opacity: 0.9;
    transition: all 0.2s ease;
    background: rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.conversation-toggle.btn:hover {
    opacity: 1;
    background: rgba(124, 58, 237, 0.08);
}


body.dark-theme .conversation-toggle.btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}



/* OUTPUT SELECTOR */

.output-type-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.output-type-selector:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark-theme .output-type-selector:hover {
    background: rgba(255, 255, 255, 0.05);
}

.output-type-button {
    display: flex;
    align-items: center;
    gap: 4px;
}

.output-type-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.output-type-dropdown-menu {
    position: absolute;
    bottom: 100%;
    right: 0px;
    margin-bottom: 4px;
    background: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 4px;
    min-width: 140px;
    display: none;
    transform: translateY(10px);
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.output-type-dropdown-menu.show {
    display: block;
}

.output-type-option {
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
    color: #aaa;
}

.output-type-option:hover {
    background: var(--color-hover);
}

.output-type-option.selected {
    color: #7C3AED;
    font-weight: 500;
}










/* Make sure these styles are in your CSS */
.canvas-item.item-active .drag-overlay {
    pointer-events: none !important;
}

/* Keep line selection overlay interactive when item is active */
.canvas-item.item-active .line-selection-overlay {
    pointer-events: all !important;
}

.canvas-item.item-active {
    /*box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);*/
}

/* Ensure interactive elements work when activated */
.canvas-item.item-active .rich-text-editor,
.canvas-item.item-active .ql-editor,
.canvas-item.item-active a,
.canvas-item.item-active button,
.canvas-item.item-active input,
.canvas-item.item-active iframe,
.canvas-item.item-active video {
    pointer-events: all !important;
}



/* Alignment guide lines */

.alignment-guide {
    position: absolute;
    background: var(--color-muted);
    opacity: 0.4;
    pointer-events: none;
    z-index: 999999999;
    box-shadow: 0 0 calc(2px / var(--zoom-scale, 0.5)) var(--color-muted);
}

/* Section center alignment guides have a dashed pattern */
.alignment-guide.section-center {
    background: transparent;
    background-image: repeating-linear-gradient(
        0deg,
        var(--color-muted),
        var(--color-muted) 4px,
        transparent 4px,
        transparent 8px
    );
    opacity: 0.6;
}

.alignment-guide.section-center.horizontal {
    background-image: repeating-linear-gradient(
        90deg,
        var(--color-muted),
        var(--color-muted) 4px,
        transparent 4px,
        transparent 8px
    );
}

.alignment-guide.horizontal {
    height: calc(0.5px / var(--zoom-scale, 1));
    width: 100%;
}

.alignment-guide.vertical {
    width: calc(0.5px / var(--zoom-scale, 1));
    height: 100%;
}

/* Highlight for aligned items */
.canvas-item.alignment-highlight {
    /*opacity: 0.4;*/
    border: 1px solid transparent !important;
    box-shadow: 0px 0px 0px calc(1px / var(--zoom-scale, 0.5)) var(--color-selected) !important;
    z-index: 999 !important;
}

/*.canvas-item.snapping {
    transition: left 0.15s ease-out, top 0.15s ease-out, width 0.15s ease-out, height 0.15s ease-out !important;
}
.canvas-item.snapping * {
    transition: none !important;
}*/


.back-to-content-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    
    display: none; /* Hidden by default */
    align-items: center;
    gap: 8px;
    
    padding: 12px 20px;
    background: var(--color-bw);
    border: 0px solid var(--color-border);
    border-radius: var(--radius-lg);
    color: var(--color-text);
    font-size: 14px;
    font-weight: 500;
    
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(8px);
    
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-to-content-btn:hover {
    background: var(--color-bg-tertiary);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.back-to-content-btn.show {
    display: flex;
    animation: slideInDown 0.3s ease;
}

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

.back-to-content-btn svg {
    flex-shrink: 0;
}




/* select layout */

.floating-sort-selector {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-sm);
    /*color: var(--color-text);*/
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    background: var(--color-bw);
    border: 1px solid var(--color-border);
    /*min-width: 120px;*/
}

.floating-sort-selector:hover {
    background: var(--color-bg-tertiary);
}

.sort-selector-button {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: space-between;
}

.sort-selector-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    flex: 1;
    white-space: nowrap;
}

.dropdown-arrow {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.floating-sort-selector.open .dropdown-arrow {
    transform: rotate(180deg);
}

.sort-dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 4px;
    background: var(--color-bw);
    border: 0px solid var(--color-border);
    border-radius: 8px;
    padding: 2px;
    min-width: 140px;
    display: none;
    transform: translateY(10px);
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.sort-dropdown-menu.show {
    display: block;
    transform: translateY(0);
}

.sort-option {
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background 0.2s ease;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.sort-option:hover {
    background: var(--color-bg-tertiary);
}

.sort-option.selected {
    color: var(--color-accent);
    font-weight: 500;
    background: var(--color-bg-tertiary);
}

/* Dark theme specific adjustments */
body.dark-theme .sort-dropdown-menu {
    background: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-theme .sort-option {
    color: #aaa;
}

body.dark-theme .sort-option.selected {
    color: #7C3AED;
}



/* Add this to your main CSS file */
.context-menu {
    position: fixed;
    background: var(--color-bw);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 4px 0;
    min-width: 160px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: transform 0.15s ease, margin-top 0.15s ease;
    backdrop-filter: blur(10px);
    margin-top: 10px;
}

.context-menu.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    margin-top: 0;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-fg);
    transition: background-color 0.15s ease;
}

.context-menu-item:hover {
   color: var(--color-muted);
}

.context-menu-item.danger {
    color: var(--color-error);
}

.context-menu-item.danger:hover {
    background: var(--color-error-bg);
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.context-menu-divider {
    height: 1px;
    background: var(--color-muted);
    margin: 4px 0;
    opacity: 0.25;
}

/* Locked item styling */
.canvas-item.locked {
    position: absolute;
}

.canvas-item.locked::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'/%3E%3Ccircle cx='12' cy='16' r='1'/%3E%3Cpath d='M7 11V7a5 5 0 1 1 10 0v4'/%3E%3C/svg%3E") no-repeat center;
    background-size: 12px 12px;
    z-index: 10;
    pointer-events: none;
}

/* Prevent dragging of locked items */
.canvas-item.locked .drag-overlay {
    cursor: not-allowed !important;
}


/* Add this to your context menu CSS */
.context-menu-item.has-submenu {
    position: relative;
}

.submenu-arrow {
    margin-left: auto;
    opacity: 0.5;
}

.context-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    background: var(--color-bw);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 4px 0;
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: all 0.15s ease;
    z-index: 10001;
    backdrop-filter: blur(10px);
}

.context-menu-item.has-submenu:hover .context-submenu,
.context-submenu:hover {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.context-submenu-item:hover {
   color: var(--color-muted);
}

.context-menu-item.ai-action {
    /*color: #7C3AED;*/
}

.context-menu-divider.ai-divider {
    /*background: linear-gradient(90deg, #7C3AED, transparent);*/
}







/*** BEGIN LOGIC NODES ITEMS ***/

/* Base Logic Item */
.logic-item {
    border: none !important;
    background: var(--color-bw) !important;
    width: 120px;
    max-width: 200px;
    min-width: 200px;
    height: 80px;
    padding: var(--space-sm) !important;
    border-radius: 24px !important;
    box-shadow: none;
}

.logic-item.selected {
    border: 1px solid rgba(0,0,0, 0.02) !important;
    box-sizing: border-box;
    background: var(--color-bw) !important;
}

/* Hide individual logic item selection styling for multi-select */
.logic-item.multi-selected {
    /* Individual styling removed for cleaner unified selection */
}

body.dark-theme .logic-item {
    background: var(--color-bw) !important;
}

body.dark-theme .logic-item.selected {
    border: 1px solid rgba(255, 255, 255, 0.02) !important;
}

body.dark-theme .logic-item.multi-selected {
    /* Individual styling removed for cleaner unified selection */
}

/* Logic Content */
.logic-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.logic-icon {
    font-size: var(--text-lg);
    margin-bottom: var(--space-xs);
    display: none;
}

.logic-label {
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    color: var(--color-fg);
    margin-bottom: var(--space-xs);
}

.logic-config {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    cursor: pointer;
}

.logic-config:hover {
    color: var(--color-text-primary);
}

/* Connection Ports - Properly Scaled */
.logic-item .connection-port {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
    opacity: 0;
    transition: opacity 0s ease;
    z-index: 10;
    transform: translateY(-50%) scale(calc(1 / var(--zoom-scale, 1)));
}

.logic-item:hover .connection-port {
    opacity: 1;
}

.connection-port:hover {
    opacity: 1 !important;
}

.logic-item .input-port {
    left: -13px;
}

.logic-item .output-port {
    right: -13px;
}

.logic-item .port-dot {
    width: 20px;
    height: 20px;
    background: #7C3AED;
    border: 10px solid var(--color-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
}

.logic-item .port-dot svg {
    color: black;
}

.dark-theme .logic-item .port-dot svg {
    color: white;
}

.dark-theme .logic-item .port-dot {
    border: 10px solid var(--color-bg);
}

.logic-item .output-port .port-dot {
    background: #3B82F6;
}

.logic-item .port-dot span {
    color: white;
    font-size: var(--text-md);
    /*font-weight: bold;*/
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logic-item .input-port .port-dot span {
    display: none;
}

/* Logic Item States */
.logic-item.delay-active {
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

.logic-item .logic-config.delay-showing {
    color: #F59E0B;
    font-weight: 500;
}

.logic-item.queue-has-items {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.logic-item.queue-full {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

.logic-item.merger-partial {
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

.logic-item.merger-complete {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

/* Action Buttons */
.queue-release-btn,
.merger-reset-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(calc(1 / var(--zoom-scale, 1)));
    z-index: 10000000000000;
}

.queue-release-btn {
    background: #F59E0B;
    color: white;
}

.merger-reset-btn {
    background: var(--color-text-secondary);
    color: white;
}

/* Config Modal - Simple Structure */
.logic-config-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.logic-config-content {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

body.dark-theme .logic-config-content {
    background: #1a1a1a;
}

.logic-config-content h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
}

.config-field {
    margin-bottom: 16px;
}

.config-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
}

.config-field input,
.config-field select {
    width: 100%;
    padding: var(--item-padding);
    border: 0px solid var(--color-muted);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    background: rgba(0, 0, 0, 0.05) !important;
    color: var(--color-text-primary);
    font-family: var(--font-main);
    margin-bottom: 2px;
}
.config-field input[type='checkbox'] {
    width: auto;
}

body.dark-theme .config-field input,
body.dark-theme .config-field select {
    background: rgba(255,255,255, 0.05) !important;
    border-color: var(--color-muted);
    color: #fff;
}

.config-field input:focus,
.config-field select:focus {
    outline: none;
    border-color: var(--color-accent);
}

.config-field small {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    line-height: 1.4;
}

.config-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.config-buttons button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: var(--font-medium);
    cursor: pointer;
    border: 1px solid transparent;
    font-family: var(--font-main);
}

.cancel-btn {
    background: transparent;
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

.cancel-btn:hover {
    background: var(--color-hover);
}

.save-btn {
    background: var(--color-accent);
    color: white;
}

.save-btn:hover {
    opacity: 0.9;
}

/* API Config Modal Enhancements */
.api-config-modal .logic-config-content {
    width: 600px;
    max-height: 700px;
    overflow-y: auto;
}

.api-config-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

body.dark-theme .api-config-tabs {
    border-bottom-color: var(--color-muted);
}

.api-tab-btn {
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
    font-family: var(--font-main);
}

.api-tab-btn.active {
    border-bottom-color: var(--color-accent);
    background: var(--color-surface-1);
    color: var(--color-text-primary);
}

.api-tab-btn:hover {
    color: var(--color-text-primary);
}

/* Header Management */
.header-item {
    display: flex;
    gap: 8px;
    margin: 5px 0;
    align-items: center;
}

.header-item input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--color-muted);
    border-radius: 4px;
    font-size: 12px;
    background: var(--color-surface-2);
    color: var(--color-text-primary);
    font-family: var(--font-main);
}

body.dark-theme .header-item input {
    background: var(--color-surface-2);
    border-color: var(--color-muted);
    color: #fff;
}

.header-item input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.remove-header-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: var(--color-danger);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-header-btn:hover {
    opacity: 0.8;
}

.add-header-btn {
    padding: 6px 12px;
    border: 1px solid var(--color-muted);
    background: var(--color-surface-1);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text-primary);
    font-family: var(--font-main);
    transition: all 0.2s ease;
}

body.dark-theme .add-header-btn {
    background: var(--color-surface-2);
    border-color: var(--color-muted);
    color: #fff;
}

.add-header-btn:hover {
    background: var(--color-hover);
}

/* Body Input */
.body-input {
    width: 100%;
    font-family: var(--font-code);
    font-size: 12px;
    padding: 8px;
    border: 1px solid var(--color-muted);
    border-radius: 4px;
    resize: vertical;
    background: var(--color-surface-2);
    color: var(--color-text-primary);
    min-height: 120px;
}

body.dark-theme .body-input {
    background: var(--color-surface-2);
    border-color: var(--color-muted);
    color: #fff;
}

.body-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* Test Button */
.test-btn {
    background: #10B981;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: var(--font-medium);
    font-family: var(--font-main);
    transition: all 0.2s ease;
}

.test-btn:hover {
    opacity: 0.9;
}

.test-btn:disabled {
    background: var(--color-text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Switch specific styles */
.conditions-container h4 {
    margin: 16px 0 12px 0;
    font-size: 16px;
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
}

.condition-item {
    margin: 12px 0;
    padding: 16px;
    border: 0px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface-1);
}

body.dark-theme .condition-item {
    background: #252525;
    border-color: #444;
}

.condition-header {
    font-size: 14px;
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
    margin-bottom: 8px;
}

.condition-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.condition-row input,
.condition-row select {
    padding: 6px 10px;
    border: 0px solid var(--color-muted);
    border-radius: 4px;
    font-size: 13px;
    background: var(--color-surface-2);
    color: var(--color-text-primary);
    min-width: 80px;
    font-family: var(--font-main);
}

body.dark-theme .condition-row input,
body.dark-theme .condition-row select {
    background: var(--color-surface-2);
    border-color: var(--color-muted);
    color: #fff;
}

/* Trigger Button */
/*.trigger-run-btn {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    background: #10B981;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: var(--font-bold);
    cursor: pointer;
    font-size: 11px;
    font-family: var(--font-main);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}
*/
.trigger-run-btn {
    position: absolute;
    bottom: 10px;
    transform: translateX(-50%);
    left: 88%;
    width: 32px;
    height: 32px;
    background: var(--color-active);
    color: var(--color-fg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    padding-left: 3px;
    padding-top: 1px;
    flex-shrink: 1;
    line-height: 32px;
}

.trigger-run-btn:hover {
    background: #059669;
    transform: translateX(-50%) scale(1.05);
}

.trigger-run-btn:active {
    transform: translateX(-50%) scale(0.95);
}

/* Scheduler Toggle Button - Same styling as trigger button */
.scheduler-toggle-btn {
    position: absolute;
    bottom: 10px;
    transform: translateX(-50%);
    left: 88%;
    width: 32px;
    height: 32px;
    background: var(--color-active);
    color: var(--color-fg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    padding-left: 3px;
    padding-top: 1px;
    flex-shrink: 1;
    line-height: 32px;
}

.scheduler-toggle-btn:hover {
    background: #059669;
    transform: translateX(-50%) scale(1.05);
}

.scheduler-toggle-btn:active {
    transform: translateX(-50%) scale(0.95);
}

/* Trigger Active State */
.logic-item.trigger-active {
    border-color: #10B981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3) !important;
    animation: trigger-pulse 0.3s ease-out;
}

@keyframes trigger-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Trigger Node Height */
.logic-item.logic-trigger {
    min-height: 80px;
}

/* Custom Payload Field */
.custom-payload-field {
    margin-top: 10px;
}

.custom-payload-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--color-muted);
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 12px;
    resize: vertical;
    background: var(--color-surface-2);
    color: var(--color-text-primary);
    min-height: 60px;
}

body.dark-theme .custom-payload-input {
    background: var(--color-surface-2);
    border-color: var(--color-muted);
    color: #fff;
}

.custom-payload-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* Test Trigger Button */
.test-trigger-btn {
    background: #F59E0B;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: var(--font-medium);
    font-family: var(--font-main);
    transition: all 0.2s ease;
}

.test-trigger-btn:hover {
    opacity: 0.9;
}

.test-trigger-btn:disabled {
    background: var(--color-text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.logic-item.api-loading {
    border-color: #F59E0B;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.logic-item.api-loading .logic-config {
    color: #F59E0B;
    font-weight: bold;
}

/*** END LOGIC NODES ITEMS ***/




/* OVERRIDES */

.canvas-item {
    border-radius: var(--radius-item) !important;
    border: 1px solid transparent !important;
    box-shadow: 0px 0px 0px calc(1px / var(--zoom-scale, 0.5)) transparent !important;
}

.canvas-item:hover:not(.section-container) {
    border-color: transparent !important;
    box-shadow: 0px 0px 0px calc(1px / var(--zoom-scale, 0.5)) var(--color-selected) !important;
}


.canvas-item:hover:has(body.drawing-mode-active) {
   
}

.section-container > .canvas-item:hover {
    border-color: transparent !important;
    box-shadow: 0px 0px 0px calc(1px / var(--zoom-scale, 0.5)) var(--color-selected) !important;
}


.canvas-item.selected {
    border: 1px solid transparent !important;
    box-shadow: 0px 0px 0px calc(1px / var(--zoom-scale, 0.5)) var(--color-selected) !important;
     /* Visible in Windows high-contrast themes */
   /* outline-color: var(--color-selected);
    outline-width: 1px;
    outline-style: solid;*/
}
.canvas-item.multi-selected {
    border: 1px solid transparent !important;
    box-shadow: 0px 0px 0px calc(2px / var(--zoom-scale, 0.5)) var(--color-accent) !important;
   
   /* outline-color: var(--color-multi-selected);
    outline-width: 1px;
    outline-style: solid;*/
}

.canvas-item.item-active {
    border: 1px solid transparent !important;
    box-shadow: 0px 0px 0px calc(2px / var(--zoom-scale, 0.5)) var(--color-accent) !important;
   

     /* Visible in Windows high-contrast themes */
  /*  outline-color: var(--color-selected);
    outline-width: 2px;
    outline-style: solid;*/
}
.section-container.drag-over{
    border-color: transparent !important;
    box-shadow: 0px 0px 0px calc(2px / var(--zoom-scale, 0.5)) var(--color-accent) !important;

}
.connection-line {
    z-index: 9999999999 !important;
}


body.drawing-mode-active .canvas-item:hover {
    box-shadow: 0px 0px 0px calc(0px / var(--zoom-scale, 0.5)) var(--color-selected) !important;
}


/* THEME OVERRIDES */

/* ========== TOOLBAR ========== */
.toolbar {
    background: transparent;
    border: none;
    padding: 20px;
    padding-left: 10px;
    /*backdrop-filter: blur(10px);*/
    /*-webkit-backdrop-filter: blur(10px);*/
}

.toolbar-group {
    display: flex;
    gap: 2px;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    margin: 0 12px;
    opacity: 0.6;
}

.toolbar-spacer {
    flex: 1;
}

/* Minimal buttons */
.tool-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    color: var(--color-text);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.tool-btn:hover {
    background: var(--color-hover);
    color: var(--color-fg);
}

.tool-btn:active {
    transform: scale(0.96);
}

.tool-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.tool-btn.danger:hover {
    color: #ff3b30;
    background: rgba(255, 59, 48, 0.1);
}

/* Minimal select */
.tool-select {
    height: 36px;
    padding: 0 32px 0 12px;
    background: transparent;
    color: var(--color-fg);
    border: 0px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-repeat: no-repeat;
    background-position: right 8px center;
    
    /* Auto width with constraints */
    width: auto;
    min-width: 100px; /* Minimum width */
    max-width: 200px; /* Maximum width (optional) */
}
.tool-select:hover {
    background: var(--color-hover);
}

.tool-select:focus {
    outline: none;
}

/* Zoom indicator */
.zoom-indicator {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
    padding: 0 8px;
}

/* Theme toggle icons */
#themeToggle .sun-icon {
    display: block;
}

#themeToggle .moon-icon {
    display: none;
}

body.dark-theme #themeToggle .sun-icon {
    display: none;
}

body.dark-theme #themeToggle .moon-icon {
    display: block;
}

/* ========== VIEWPORT ========== */
#viewport {
    background: black;
    top: 0px;
}

/* ========== CANVAS ============ */

#canvas {
/*    border: 10px solid black;
    box-sizing: border-box;
*/}


/* ========== CANVAS ITEMS ========== */
.canvas-item {
    background: var(--color-surface);
    border: 1px solid transparent;
    border-radius: var(--radius);
    box-shadow: none;
    transition: var(--transition);
}

.canvas-item:not(.selected):hover {
    border-color: rgba(0, 0, 0, 0.1);
}

body.dark-theme .canvas-item:not(.selected):hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.canvas-item.selected {
    border-color: var(--color-accent);
}

/* Minimal delete button */
/*.delete-btn {
    width: 24px;
    height: 24px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-size: 16px;
    opacity: 0;
    transition: var(--transition);
    z-index: 10;
    position: absolute;
}*/

/* Only show delete buttons when hovering direct items, not section containers */
.canvas-item:hover:not(.section-container) .delete-btn {
    opacity: 1;
}

.section-container > .canvas-item:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    background: #ff3b30;
    border-color: #ff3b30;
    color: white;
}

.resize-handle {
    z-index: 10;
    position: absolute;
}

/* Resize handle */
.resize-handle::before {
    border-color: var(--color-text);
    opacity: 0.3;
}

/* Only show resize handle hover when hovering direct items, not section containers */
.canvas-item:hover:not(.section-container) .resize-handle::before {
    opacity: 0.6;
}

.section-container > .canvas-item:hover .resize-handle::before {
    opacity: 0.6;
}

/* Text items */
.text-item {
    background: transparent;
    /*background: var(--color-surface);*/
}

/*.rich-text-editor {
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-fg);
}

.rich-text-editor:empty:before {
    color: var(--color-text);
}
*/
/* Code items */
.code-item {
    background: #1a1a1a !important;
}

.code-item pre {
     font-family: var(--font-code-main) !important;
}

/* Link items */
.link-item {
    background: var(--color-surface);
}

.link-title {
    /*font-weight: 500;*/
}

/* Image items */
.image-item {
    /*border: none;*/
    /*background: transparent !important;*/
}

/* ========== GREENISH MULTI-SELECT ========== */

/* Multi-selected items */
.canvas-item.multi-selected {
    border-color: var(--color-accent);
    border-width: 2px;
    box-sizing: border-box;
    background: var(--backgroundcolor-accent);
    /*background: rgba(16, 163, 127, 0.03);*/
    /*animation: multiSelectPulse 300ms cubic-bezier(0.4, 0, 0.2, 1);*/
}

@keyframes multiSelectPulse {
    0% {
        transform: scale(0.98);
        border-color: rgba(16, 163, 127, 0.5);
    }
    50% {
        transform: scale(1.01);
        border-color: rgba(16, 163, 127, 1);
    }
    100% {
        transform: scale(1);
        border-color: var(--color-accent);
    }
}

/* Multi-select overlay */
.multi-select-overlay {
    /*background: linear-gradient(135deg, 
        rgba(16, 163, 127, 0.05) 0%, 
        rgba(16, 163, 127, 0.02) 100%);*/
    border-radius: var(--radius);
    animation: overlayFadeIn 200ms ease-out;
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Selection box */
.selection-box {
    border: 1px solid var(--color-accent);
    background: var(--backgroundcolor-accent);
    animation: selectionGrow 100ms ease-out;
}

@keyframes selectionGrow {
    from {
        opacity: 0.5;
    }
    to {
        opacity: 1;
    }
}

/* Shift-hover overlay */
.shift-hover-overlay {
    background: transparent;
    transition: background 150ms ease;
}

body.shift-held .canvas-item:hover .shift-hover-overlay {
    /*background: rgba(16, 163, 127, 0.08);*/
    cursor: pointer;
}

/* Multiple items selected - stronger visual feedback */
.canvas-item.multi-selected:nth-child(odd) {
    animation-delay: 50ms;
}

.canvas-item.multi-selected:nth-child(even) {
    animation-delay: 100ms;
}

/* Dark theme multi-select adjustments */
body.dark-theme .canvas-item.multi-selected {
    border-color: var(--color-accent);
    /*background: rgba(25, 195, 125, 0.05);*/
}

body.dark-theme .selection-box {
    border-color: var(--color-accent);
    /*background: rgba(25, 195, 125, 0.1);*/
}

body.dark-theme .multi-select-overlay {
  /*  background: linear-gradient(135deg, 
        rgba(25, 195, 125, 0.08) 0%, 
        rgba(25, 195, 125, 0.03) 100%);*/
}

/* ========== SELECTION TOOLBAR ========== */
.selection-toolbar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body.dark-theme .selection-toolbar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.selection-toolbar button {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 13px;
}

.selection-toolbar button:hover {
    background: var(--color-hover);
}

.selection-toolbar button.active {
    background: var(--color-accent);
    color: white;
}

.toolbar-separator {
    background: var(--color-border);
    opacity: 0.5;
}

/* ========== HELP MODAL ========== */
.help-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

body.dark-theme .help-modal {
    background: rgba(0, 0, 0, 0.6);
}

.help-modal.show {
    display: flex;
}

.help-modal-content {
    background: var(--color-surface);
    border-radius: 16px;
    max-width: 480px;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    animation: modalSlideIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.help-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 20px;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.help-modal-close:hover {
    background: var(--color-hover);
    color: var(--color-fg);
}

.help-modal h2 {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.help-section {
    margin-bottom: 20px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
}

.help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-section li {
    padding: 6px 0;
    font-size: 13px;
    color: var(--color-text);
    line-height: 1.5;
}

.help-section strong {
    color: var(--color-fg);
    font-weight: 500;
}

/* ========== MINIMAL SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 10px;
}

/* Modal scrollbar */
.help-modal-content::-webkit-scrollbar {
    width: 6px;
}

/* Remove all unnecessary shadows */
* {
    box-shadow: none !important;
}

/* Only allow specific shadows */
.selection-toolbar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

body.dark-theme .selection-toolbar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.delete-btn {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

/* Focus states */
:focus {
    outline: none;
}

/* Drag states */
.canvas-item.dragging {
    opacity: 0.8;
}

/* Checkboxes */
.checkbox-wrapper input[type="checkbox"] {
    accent-color: var(--color-accent);
}

/* Preparing to drag - subtle pulse */
.canvas-item.preparing-drag {
    animation: holdPulse 0.4s ease-in-out;
}

@keyframes holdPulse {
    0% {
        transform: scale(1);
        border-color: var(--color-border);
    }
    50% {
        transform: scale(0.95);
        border-color: var(--color-accent);
    }
    100% {
        transform: scale(1);
        border-color: var(--color-accent);
    }
}

/* Ready to drag - visual feedback */
.canvas-item.drag-ready {
    border-color: var(--color-accent);
    /*background: rgba(16, 163, 127, 0.02);*/
    /*transform: scale(0.98);*/
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dragging state */
.canvas-item.dragging {
    opacity: 0.85;
    /*transform: scale(0.98);*/
    transition: opacity 150ms ease;
    cursor: grabbing !important;
}

/* Release animation - snap back */
.canvas-item:not(.dragging):not(.preparing-drag):not(.drag-ready) {
    transition: transform 20ms cubic-bezier(0.4, 0, 0.2, 1),
                border-color 200ms ease,
                background 10s0ms ease;
}

/* Dark theme adjustments */
body.dark-theme .canvas-item.drag-ready {
    background: rgba(25, 195, 125, 0.03);
}

/* Prevent animation conflicts with multi-select */
.canvas-item.multi-selected.preparing-drag {
    animation: none;
}

.canvas-item.multi-selected.drag-ready {
    transform: scale(0.98);
}

/* Smooth cursor transitions */
.canvas-item {
    /*cursor: move;*/
}

.canvas-item.preparing-drag,
.canvas-item.drag-ready {
    cursor: grab;
}

.canvas-item.dragging {
    cursor: grabbing !important;
}


.embed-item .iframe-wrapper {
    /*position: relative;*/
    /*pointer-events: none; /* Disable iframe interaction by default */*/
}

.embed-item iframe {
    /*pointer-events: none; /* Disable iframe interaction by default */*/
}

/* Enable iframe interaction only when not hovering controls */
.embed-item:not(:hover) .iframe-wrapper,
.embed-item:not(:hover) iframe {
    /*pointer-events: auto;*/
}

/* Ensure controls are always interactive */
.embed-item .delete-btn,
.embed-item .resize-handle {
    /*pointer-events: auto !important;*/
}

/* Optional: Add a subtle overlay on hover to make controls more visible */
/*.embed-item:hover .iframe-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.05);
    pointer-events: none;
    border-radius: var(--radius);
}*/

body.dark-theme .embed-item:hover .iframe-wrapper::after {
    background: rgba(255, 255, 255, 0.05);
}


.model-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    padding: 12px;
    text-align: center;
}

.model-dropdown:empty::after {
    content: 'No API keys configured';
    padding: 12px;
    color: #666;
    display: block;
    text-align: center;
}

/* Scheduler Node Styles */
.logic-item.scheduler-active {
    border-color: #10B981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3) !important;
}

.logic-item.scheduler-paused {
    border-color: #F59E0B !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3) !important;
}

.logic-item.scheduler-error {
    border-color: #EF4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4) !important;
    animation: scheduler-error-pulse 0.6s ease-out;
}

.logic-item.trigger-active {
    animation: scheduler-trigger-pulse 0.3s ease-out;
}

@keyframes scheduler-error-pulse {
    0% { 
        transform: scale(1);
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.6);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4);
    }
}

@keyframes scheduler-trigger-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.scheduler-start-btn,
.scheduler-pause-btn,
.scheduler-stop-btn {
    background: none;
    border: 1px solid var(--color-muted);
    color: var(--color-text);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.scheduler-start-btn:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10B981;
    color: #10B981;
}

.scheduler-pause-btn:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: #F59E0B;
    color: #F59E0B;
}

.scheduler-stop-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #EF4444;
    color: #EF4444;
}