        :root {
            /* Light theme variables */
            --bg-primary: #f8fafc;
            --bg-secondary: #e2e8f0;
            --bg-surface: #ffffff;
            --bg-surface-alt: #f8fafc;
            --text-primary: #1e293b;
            --text-secondary: #64748b;
            --text-tertiary: #374151;
            --border-color: #e2e8f0;
            --border-color-strong: #cbd5e1;
            --shadow-color: rgba(0, 0, 0, 0.1);
            --shadow-color-strong: rgba(0, 0, 0, 0.15);
            --grid-color: #cbd5e1;
            --backdrop-blur: rgba(255, 255, 255, 0.8);
            --primary-color: #3b82f6;
            --primary-color-strong: #2563eb;
        }

        [data-theme="dark"] {
            /* Dark theme variables */
            --bg-primary: #111111;
            --bg-secondary: #1f1f1f;
            --bg-surface: #404040;
            --bg-surface-alt: #555555;
            --text-primary: #f1f5f9;
            --text-secondary: #cbd5e1;
            --text-tertiary: #e2e8f0;
            --border-color: #555555;
            --border-color-strong: #6b6b6b;
            --shadow-color: rgba(0, 0, 0, 0.3);
            --shadow-color-strong: rgba(0, 0, 0, 0.5);
            --grid-color: #555555;
            --backdrop-blur: rgba(64, 64, 64, 0.8);
            --primary-color: #60a5fa;
            --primary-color-strong: #3b82f6;
        }

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

        body {
            font-family: system-ui, -apple-system, sans-serif;
            height: 100vh;
            background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
            overflow: hidden;
            --animation-duration: 0.2s;
            transition: background 0.3s ease;
            cursor: default;
            user-select: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
        }

        body * {
            user-select: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
        }

        button,
        a,
        select,
        input[type="color"],
        input[type="range"],
        .app-icon,
        .section-header,
        .custom-color-swatch,
        .canvas-context-menu-item {
            cursor: pointer;
        }

        input:is([type="text"], [type="number"], [type="email"], [type="url"], [type="search"], [type="tel"], [type="password"]),
        textarea,
        [contenteditable]:not([contenteditable="false"]),
        [contenteditable]:not([contenteditable="false"]) * {
            cursor: text;
            user-select: text;
            -webkit-user-select: text;
            -moz-user-select: text;
            -ms-user-select: text;
        }


        .startup-loader {
            position: fixed;
            inset: 0;
            z-index: 4000;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
            transition: opacity 0.2s ease, visibility 0.2s ease;
        }

        .startup-loader.is-hidden {
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
        }

        .startup-loader__content {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.5rem;
            color: var(--text-secondary);
            letter-spacing: 0.02em;
        }

        .startup-loader__spinner {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            border: 2px solid var(--border-color);
            border-top-color: var(--text-primary);
            animation: startup-loader-spin 0.8s linear infinite;
        }

        .startup-loader__label {
            font-size: 0.8rem;
            font-weight: 500;
            color: var(--text-secondary);
            user-select: none;
        }

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

        .header {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            z-index: 100;
            background: var(--backdrop-blur);
            backdrop-filter: blur(8px);
            border-bottom: 1px solid var(--border-color);
            transition: right 0.3s ease;
        }

        .header.sidebar-open {
            right: 280px;
        }

        .header-content {
            display: flex;
            align-items: center;
            padding: 1rem 1.5rem;
            position: relative;
        }

        .header-left {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .header-center {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .toolbar {
            display: flex;
            gap: 0.75rem;
            align-items: center;
            margin-left: auto;
        }

        .btn-support {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            border-radius: 0.5rem;
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            cursor: pointer;
            transition: all 0.2s;
            color: var(--text-primary);
            font-size: 0.875rem;
            font-weight: 500;
            text-decoration: none;
        }

        .btn-support:hover {
            background: var(--bg-surface-alt);
            transform: translateY(-1px);
            box-shadow: 0 2px 8px var(--shadow-color);
        }

        .btn-support svg {
            width: 18px;
            height: 18px;
        }

        .btn-support .heart-icon {
            fill: #ef4444;
            transition: transform 0.2s ease;
        }

        .btn-support:hover .heart-icon {
            transform: scale(1.1);
            fill: #dc2626;
        }

        .app-icon {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            cursor: pointer;
            transition: all 0.2s ease;
            user-select: none;
            position: relative;
        }

        .app-icon:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        }

        .app-icon:active {
            transform: translateY(0px);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .app-icon-img {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            transition: all 0.2s ease;
        }

        [data-theme="dark"] .light-icon {
            display: none !important;
        }

        [data-theme="dark"] .dark-icon {
            display: block !important;
        }

        .header h1 {
            font-size: 1.5rem;
            font-weight: bold;
            color: var(--text-primary);
            position: relative;
            cursor: default;
        }

        .app-version {
            position: absolute;
            top: -0.2rem;
            right: -2rem;
            font-size: 0.5rem;
            font-weight: normal;
            color: var(--text-secondary);
            opacity: 0;
            transition: opacity 0.2s ease;
            pointer-events: none;
            background: var(--bg-surface);
            padding: 0.125rem 0.25rem;
            border-radius: 0.25rem;
            border: 1px solid var(--border-color);
            box-shadow: 0 2px 4px var(--shadow-color);
            white-space: nowrap;
        }

        .header h1:hover .app-version {
            opacity: 1;
        }

        .search-container-sidebar {
            position: relative;
            display: flex;
            align-items: center;
            width: 100%;
            margin-bottom: 0.5rem;
        }

        .search-input-sidebar {
            width: 100%;
            padding: 0.75rem 2.5rem 0.75rem 1rem;
            border-radius: 0.5rem;
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            font-size: 0.875rem;
            outline: none;
            transition: all 0.2s ease;
        }

        .search-input-sidebar:focus {
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .search-input-sidebar::placeholder {
            color: var(--text-secondary);
        }

        .search-icon {
            position: absolute;
            right: 0.75rem;
            color: var(--text-secondary);
            pointer-events: none;
        }

        .search-clear-btn {
            position: absolute;
            right: 2.5rem;
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-secondary);
            padding: 0.25rem;
            border-radius: 0.25rem;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .search-clear-btn:hover {
            color: var(--text-primary);
            background: var(--bg-surface-alt);
        }

        .search-results-count {
            position: absolute;
            right: 3.5rem;
            font-size: 0.75rem;
            color: var(--text-secondary);
            background: var(--bg-surface-alt);
            padding: 0.125rem 0.375rem;
            border-radius: 0.25rem;
            pointer-events: none;
            white-space: nowrap;
        }

        .search-help {
            margin-top: 0.5rem;
        }

        .search-help p {
            font-size: 0.75rem;
            color: var(--text-secondary);
            margin: 0;
            line-height: 1.4;
        }

        .btn {
            padding: 0.5rem;
            border-radius: 0.5rem;
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-primary);
        }

        .icon-mask {
            width: 18px;
            height: 18px;
            background-color: currentColor;
            -webkit-mask-size: contain;
            mask-size: contain;
            -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
            -webkit-mask-position: center;
            mask-position: center;
            display: inline-block;
        }

        .btn:hover {
            background: var(--bg-surface-alt);
        }

        .btn-settings {
            background: var(--bg-surface);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-settings:hover {
            background: var(--bg-surface-alt);
        }

        .btn-settings.active {
            background: var(--bg-surface-alt);
            border-color: var(--border-color-strong);
        }

        .btn-theme {
            background: var(--bg-surface);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
            transition: all 0.2s ease;
        }

        .btn-theme:hover {
            background: var(--bg-surface-alt);
            transform: scale(1.05);
        }

        .btn-theme.dark-mode {
            background: #1f1f1f;
            color: #f1f5f9;
            border-color: #555555;
        }

        .btn-theme.dark-mode:hover {
            background: #404040;
        }

        .btn-help {
            background: var(--bg-surface);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-help:hover {
            background: var(--bg-surface-alt);
        }

        [data-theme="dark"] .btn-help:hover {
            background: #1f1f1f;
            border-color: #6b6b6b;
        }

        #helpBtn .icon-mask {
            -webkit-mask-image: url('icons/information.svg');
            mask-image: url('icons/information.svg');
        }

        [data-theme="dark"] #helpBtn .icon-mask {
            -webkit-mask-image: url('icons/information--filled.svg');
            mask-image: url('icons/information--filled.svg');
        }

        /* Sidebar Styles */
        .sidebar {
            position: fixed;
            top: 0;
            right: -280px;
            width: 280px;
            height: 100vh;
            background: var(--bg-surface);
            border-left: 1px solid var(--border-color);
            z-index: 90;
            transition: right 0.3s ease;
            box-shadow: -2px 0 10px var(--shadow-color);
            overflow-y: auto;
            overflow-x: hidden;
            display: flex;
            flex-direction: column;
        }

        .sidebar.open {
            right: 0;
        }

        .sidebar-header {
            padding: 1rem 1.5rem;
            border-bottom: 1px solid var(--border-color);
            background: var(--bg-surface-alt);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .sidebar-title {
            font-size: 1.5rem;
            font-weight: bold;
            color: var(--text-primary);
            margin: 0;
            cursor: pointer;
            user-select: none;
            transition: opacity 0.2s;
        }

        .sidebar-title:hover {
            opacity: 0.7;
        }

        .sidebar-subtitle {
            font-size: 0.875rem;
            color: var(--text-secondary);
        }

        .sidebar-content {
            padding: 1.5rem;
            max-width: 100%;
            box-sizing: border-box;
            flex: 1;
        }

        .settings-section {
            margin-bottom: 2rem;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
        }

        .section-header {
            cursor: pointer;
            user-select: none;
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 0.5rem;
            padding: 0.5rem;
            margin-left: -0.5rem;
            margin-right: -0.5rem;
            border-radius: 6px;
            transition: background-color 0.2s ease;
        }

        .section-header:hover {
            background-color: var(--bg-surface-alt);
        }

        .section-title {
            font-size: 0.875rem;
            font-weight: 600;
            color: var(--text-tertiary);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin: 0;
            transition: color 0.2s ease;
        }

        .section-toggle {
            width: 16px;
            height: 16px;
            stroke: var(--text-secondary);
            transition: transform 0.2s ease, stroke 0.2s ease;
        }

        .section-header:hover .section-title {
            color: var(--text-primary);
        }

        .section-header:hover .section-toggle {
            stroke: #3b82f6;
        }

        .section-content {
            transition: all 0.3s ease;
            overflow: hidden;
        }

        .settings-section.collapsed .section-content {
            max-height: 0;
            opacity: 0;
        }

        .settings-section.collapsed .section-toggle {
            transform: rotate(-90deg);
        }

        .setting-group {
            margin-bottom: 1.5rem;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
            overflow: hidden;
        }

        .setting-label {
            display: block;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-primary);
            margin-bottom: 0.5rem;
        }

        .connection-style-dropdown {
            position: relative;
            margin-bottom: 1rem;
        }

        .style-select {
            width: 100%;
            padding: 0.75rem;
            border-radius: 0.5rem;
            background-color: var(--bg-surface);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            font-size: 0.875rem;
            font-weight: 500;
            cursor: pointer;
            appearance: none;
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
            background-position: right 0.75rem center;
            background-repeat: no-repeat;
            background-size: 1.5em 1.5em;
            padding-right: 2.5rem;
        }

        .style-select:hover {
            background-color: var(--bg-surface-alt);
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
            background-position: right 0.75rem center;
            background-repeat: no-repeat;
            background-size: 1.5em 1.5em;
        }

        .style-select:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        [data-theme="dark"] .style-select {
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
            background-position: right 0.75rem center;
            background-repeat: no-repeat;
            background-size: 1.5em 1.5em;
        }

        [data-theme="dark"] .style-select:hover {
            background-color: var(--bg-surface-alt);
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
            background-position: right 0.75rem center;
            background-repeat: no-repeat;
            background-size: 1.5em 1.5em;
        }

        .single-color-picker {
            margin-top: 0.75rem;
            padding: 0.75rem;
            background: var(--bg-surface-alt);
            border-radius: 0.5rem;
            border: 1px solid var(--border-color);
            position: relative;
            z-index: 1;
        }

        .color-picker-input-container {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            margin-top: 0.5rem;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
            overflow: visible;
        }

        .color-picker-input-container input[type="color"] {
            width: 50px;
            min-width: 50px;
            height: 32px;
            flex-shrink: 0;
            border: 1px solid var(--border-color);
            border-radius: 0.25rem;
            cursor: pointer;
            background: none;
            padding: 0;
            transition: all 0.2s ease;
        }

        .color-picker-input-container input[type="color"]:hover {
            transform: scale(1.05);
            border-color: var(--border-color-strong);
            box-shadow: 0 2px 8px var(--shadow-color);
        }

        .color-picker-input-container input[type="color"]::-webkit-color-swatch-wrapper {
            padding: 0;
            border: none;
            border-radius: 0.25rem;
        }

        .color-picker-input-container input[type="color"]::-webkit-color-swatch {
            border: none;
            border-radius: 0.25rem;
        }

        .color-picker-hex-input {
            flex: 1;
            min-width: 0;
            height: 32px;
            padding: 0.375rem 0.75rem;
            border: 1px solid var(--border-color);
            border-radius: 0.25rem;
            font-size: 0.875rem;
            font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
            text-align: center;
            background: var(--bg-surface);
            color: var(--text-primary);
            transition: all 0.2s ease;
            cursor: text;
            pointer-events: auto;
            user-select: text;
            -webkit-user-select: text;
            -moz-user-select: text;
            -ms-user-select: text;
            box-sizing: border-box;
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .color-picker-hex-input:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .color-picker-hex-input:hover {
            border-color: var(--border-color-strong);
        }

        .custom-color-section {
            border-top: 1px solid var(--border-color);
            padding: 8px 4px 0 4px;
            margin-top: 8px;
            width: 100%;
            box-sizing: border-box;
        }

        .custom-color-label {
            font-size: 12px;
            color: var(--text-secondary);
            margin-bottom: 6px;
            font-weight: 500;
        }

        .custom-color-picker {
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
            box-sizing: border-box;
        }

        .custom-color-swatch {
            width: 32px;
            height: 32px;
            border: 2px solid var(--border-color);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            background: #ffffff;
            overflow: hidden;
        }

        .custom-color-swatch:hover {
            border-color: var(--border-color-strong);
            transform: scale(1.05);
        }

        .custom-color-swatch input[type="color"] {
            width: 100%;
            height: 100%;
            border: none;
            outline: none;
            cursor: pointer;
            background: none;
        }

        .custom-color-swatch input[type="color"]::-webkit-color-swatch-wrapper {
            padding: 0;
            border: none;
        }

        .custom-color-swatch input[type="color"]::-webkit-color-swatch {
            border: none;
            border-radius: 4px;
        }

        .custom-hex-input {
            flex: 1;
            padding: 6px 8px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            font-size: 12px;
            font-family: monospace;
            background: var(--bg-surface);
            color: var(--text-primary);
            transition: all 0.2s ease;
            min-width: 0;
            max-width: calc(100% - 8px);
            margin-right: 4px;
        }

        .custom-hex-input:focus {
            outline: none;
            border-color: #6366f1;
            box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
        }

        .custom-hex-input:hover {
            border-color: var(--border-color-strong);
        }

        .dash-toggle-container {
            margin-top: 0.75rem;
        }

        .dash-toggle {
            width: 100%;
            padding: 0.75rem;
            border-radius: 0.5rem;
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            color: var(--text-primary);
        }

        .dash-toggle:hover {
            background: var(--bg-surface-alt);
        }

        .dash-toggle.active {
            background: #3b82f6;
            color: white;
            border-color: #3b82f6;
        }

        .dash-toggle.active:hover {
            background: #2563eb;
        }

        .dash-toggle.active:hover {
            background: #2563eb;
        }

        .segmented-control {
            display: flex;
            background: var(--bg-surface-alt);
            padding: 4px;
            border-radius: 8px;
            gap: 4px;
            border: 1px solid var(--border-color);
        }

        .segmented-btn {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 6px;
            border: none;
            background: transparent;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            color: var(--text-secondary);
        }

        .segmented-btn:hover {
            background: rgba(0, 0, 0, 0.05);
            color: var(--text-primary);
        }

        [data-theme="dark"] .segmented-btn:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        .segmented-btn.active {
            background: var(--bg-surface);
            box-shadow: 0 1px 3px var(--shadow-color);
            color: #3b82f6;
        }

        .segmented-btn .icon-mask {
            width: 20px;
            height: 20px;
        }

        .segmented-btn span {
            font-size: 13px;
            font-weight: 600;
        }

        .canvas-container {
            position: relative;
            width: 100vw;
            height: 100vh;
            padding-top: 80px;
            padding-left: 60px;
            overflow: hidden;
            transition: padding-right 0.3s ease;
            touch-action: none;
            /* Prevent default touch behaviors for better gesture handling */
        }

        .canvas-container.sidebar-open {
            padding-right: 280px;
        }

        .connections-canvas {
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
            overflow: visible;
        }

        .draw-canvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 5;
            overflow: visible;
            pointer-events: none;
        }

        .connection-path {
            pointer-events: stroke;
            stroke-width: 12;
            /* Invisible wider stroke for easier hovering */
            stroke: transparent;
            cursor: pointer;
            cursor: pointer;
        }

        .connection-path:hover+.connection-visual {
            filter: brightness(1.2);
        }

        .connection-visual {
            pointer-events: none !important;
            transition: opacity 0.2s ease, filter 0.2s ease;
        }

        .connection-visual.selected {
            opacity: 1 !important;
            filter: brightness(0.7);
            animation: connectionPulse 1.5s ease-in-out infinite;
        }

        [data-theme="dark"] .connection-visual.selected {
            filter: brightness(1.4);
        }

        @keyframes connectionPulse {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.7;
            }
        }

        .connections-canvas rect,
        .connections-canvas defs,
        .connections-canvas pattern {
            pointer-events: none !important;
        }

        .connection-add-btn {
            position: absolute;
            width: 20px;
            height: 20px;
            background: #10b981;
            border-radius: 50%;
            display: none;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s ease;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
            z-index: 15;
            border: 2px solid white;
        }

        .connection-add-btn:hover {
            background: #059669;
            transform: scale(1.1);
        }

        .connection-add-btn.delete-mode {
            background: #ef4444;
        }

        .connection-add-btn.delete-mode:hover {
            background: #dc2626;
        }

        .connection-add-btn.show {
            opacity: 1;
            visibility: visible;
            display: flex;
        }

        .connection-add-btn svg {
            width: 12px;
            height: 12px;
            stroke: white;
            stroke-width: 2.5;
        }

        .nodes-container {
            position: absolute;
            top: 0;
            left: 0;
            z-index: 10;
            overflow: visible;
        }

        .node {
            position: absolute;
            min-width: 80px;
            min-height: 40px;
            background: #6366f1;
            border-radius: 20px;
            /* This will be updated dynamically */
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all var(--animation-duration, 0.2s);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            padding: 8px 16px;
            user-select: none;
        }

        .node:hover {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            transform: scale(1.05);
        }

        .node.editing:hover {
            transform: none;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        .node.editing {
            transition: none;
        }

        /* While renaming, the hover/selection affordances only crowd the input
           and risk swallowing a click meant to place the caret - hide them. */
        .node.editing .add-child-btn,
        .node.editing .collapse-branch-btn,
        .node.editing .resize-handle {
            opacity: 0 !important;
            visibility: hidden !important;
        }

        .node:hover .add-child-btn {
            opacity: 1;
            visibility: visible;
        }

        /* ----- Branch collapse ----- */
        .collapse-branch-btn {
            position: absolute;
            bottom: -8px;
            left: -8px;
            min-width: 22px;
            height: 22px;
            padding: 0 5px;
            border: 2px solid var(--bg-primary);
            border-radius: 11px;
            background: var(--text-secondary);
            color: #ffffff;
            font-size: 11px;
            font-weight: 700;
            font-variant-numeric: tabular-nums;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            visibility: hidden;
            transition: all var(--animation-duration, 0.2s);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            z-index: 10;
        }

        .collapse-branch-btn svg {
            width: 14px;
            height: 14px;
            stroke: currentColor;
            stroke-width: 2.5;
            stroke-linecap: round;
        }

        .node:hover .collapse-branch-btn,
        .node.selected .collapse-branch-btn,
        .collapse-branch-btn:focus-visible {
            opacity: 1;
            visibility: visible;
        }

        /* A folded branch has to advertise itself even when nothing is hovering it -
           otherwise the hidden nodes are simply gone with no way back. */
        .collapse-branch-btn.is-collapsed {
            opacity: 1;
            visibility: visible;
            background: var(--primary-color);
        }

        .collapse-branch-btn:hover {
            transform: scale(1.1);
            background: var(--primary-color-strong);
        }

        /* Stacked edge behind a collapsed node, hinting at the branch tucked underneath. */
        .node.branch-collapsed::after {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: inherit;
            background: inherit;
            opacity: 0.45;
            transform: translate(5px, 5px);
            z-index: -1;
            pointer-events: none;
        }

        .resize-handle {
            position: absolute;
            bottom: 0;
            right: 0;
            width: 16px;
            height: 16px;
            cursor: nwse-resize;
            z-index: 20;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .resize-handle::after {
            content: '';
            position: absolute;
            bottom: 4px;
            right: 4px;
            width: 8px;
            height: 8px;
            border-right: 2px solid var(--text-secondary);
            border-bottom: 2px solid var(--text-secondary);
        }

        .node:hover .resize-handle,
        .node.selected .resize-handle {
            opacity: 1;
        }

        .node-image {
            max-width: 150px;
            max-height: 150px;
            object-fit: cover;
            border-radius: 4px;
            display: block;
            margin-bottom: 0;
            pointer-events: none;
        }

        .node.image-node {
            padding: 8px;
            flex-direction: column;
        }

        .node.image-node:hover {
            transform: none;
        }

        .node.dragging .add-child-btn {
            opacity: 0;
            visibility: hidden;
        }

        /* Hide all add buttons and connection add button during add button drag operation */
        body.add-button-dragging .add-child-btn {
            opacity: 0 !important;
            visibility: hidden !important;
        }

        body.add-button-dragging .connection-add-btn {
            opacity: 0 !important;
            visibility: hidden !important;
        }

        /* Hide all add buttons and connection add button during gesture operations */
        body.gesture-active .add-child-btn {
            opacity: 0 !important;
            visibility: hidden !important;
        }

        body.gesture-active .connection-add-btn {
            opacity: 0 !important;
            visibility: hidden !important;
        }

        /* Hide all add buttons and connection add button during marquee selection */
        body.marquee-active .add-child-btn {
            opacity: 0 !important;
            visibility: hidden !important;
        }

        body.marquee-active .connection-add-btn {
            opacity: 0 !important;
            visibility: hidden !important;
        }

        /* Hide add affordances while drawing or dragging draw strokes */
        body.draw-affordances-hidden .add-child-btn {
            opacity: 0 !important;
            visibility: hidden !important;
        }

        body.draw-affordances-hidden .connection-add-btn {
            opacity: 0 !important;
            visibility: hidden !important;
        }

        .add-child-btn {
            position: absolute;
            top: -8px;
            right: -8px;
            width: 24px;
            height: 24px;
            background: #10b981;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            visibility: hidden;
            transition: all var(--animation-duration, 0.2s);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            z-index: 10;
        }

        .add-child-btn:hover {
            background: #059669;
            transform: scale(1.1);
        }

        .add-child-btn.delete-mode {
            background: #ef4444;
        }

        .add-child-btn.delete-mode:hover {
            background: #dc2626;
        }

        .add-child-btn svg {
            width: 14px;
            height: 14px;
            stroke: white;
            stroke-width: 2.5;
        }

        .node.selected {
            outline: 3px solid white;
            outline-offset: 2px;
        }

        /* Connections are re-pathed instantly on every drag frame, so left/top must
           not animate here or the node trails behind its lines (rubber-banding).
           Only the lift effect keeps its transition. */
        .node.dragging {
            transform: scale(1.1);
            z-index: 1000;
            transition: transform var(--animation-duration, 0.2s), box-shadow var(--animation-duration, 0.2s);
        }

        .node.image-node.dragging {
            transform: none;
            z-index: 1000;
        }

        .node.dragging.selected {
            outline: 3px solid white;
            outline-offset: 2px;
        }

        .node.dragging.multi-selected {
            outline: 3px solid white;
            outline-offset: 2px;
        }

        .node-text {
            color: white;
            font-weight: 600;
            font-size: 12px;
            text-align: center;
            white-space: nowrap;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
            pointer-events: none;
            user-select: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            -webkit-touch-callout: none;
        }

        .node-text::selection,
        .node::selection {
            background: transparent;
        }

        .node-input {
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            outline: none;
            border-radius: 10px;
            padding: 4px 8px;
            font-size: 12px;
            font-weight: 600;
            text-align: center;
            color: var(--text-primary);
            min-width: 60px;
            height: 24px;
            line-height: 1.2;
            box-sizing: border-box;
        }

        .node.editing .node-input {
            text-align: left;
        }

        .floating-panel {
            position: absolute;
            bottom: 1.5rem;
            left: 50%;
            transform: translateX(-50%);
            background: var(--bg-surface);
            border-radius: 0.75rem;
            box-shadow: 0 10px 25px var(--shadow-color);
            border: 1px solid var(--border-color);
            padding: 0.5rem;
            display: none;
            align-items: center;
            gap: 0.5rem;
            z-index: 50;
        }

        .floating-panel.show {
            display: flex;
        }

        .action-btn {
            width: 2.75rem;
            height: 2.75rem;
            flex-shrink: 0;
            padding: 0;
            border-radius: 0.5rem;
            border: none;
            cursor: pointer;
            transition: all 0.2s;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .btn-add {
            background: #3b82f6;
        }

        .btn-add:hover {
            background: #2563eb;
        }

        .btn-edit {
            background: var(--bg-surface);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-edit:hover {
            background: var(--bg-surface-alt);
        }

        .btn-delete {
            background: #ef4444;
        }

        .btn-delete:hover {
            background: #dc2626;
        }

        .btn-disconnect {
            background: var(--bg-surface);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-disconnect:hover {
            background: var(--bg-surface-alt);
        }

        .btn-connect {
            background: var(--bg-surface);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-connect:hover {
            background: var(--bg-surface-alt);
        }

        .marquee {
            position: absolute;
            border: 2px dashed #3b82f6;
            background: rgba(59, 130, 246, 0.1);
            pointer-events: none;
            z-index: 50;
            display: none;
        }

        .node.multi-selected {
            outline: 3px solid white;
            outline-offset: 2px;
        }

        .node.search-highlight {
            animation: searchPulse 1.5s ease-in-out infinite;
            box-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
        }

        @keyframes searchPulse {

            0%,
            100% {
                box-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
            }

            50% {
                box-shadow: 0 0 30px rgba(59, 130, 246, 0.9);
            }
        }

        .node.drop-target {
            outline: 3px solid #10b981;
            outline-offset: 2px;
            box-shadow: 0 0 20px rgba(16, 185, 129, 0.6);
            animation: dropTargetPulse 0.8s ease-in-out infinite;
        }

        @keyframes dropTargetPulse {

            0%,
            100% {
                box-shadow: 0 0 20px rgba(16, 185, 129, 0.6);
            }

            50% {
                box-shadow: 0 0 30px rgba(16, 185, 129, 0.9);
            }
        }

        /* Preview node styles for drag operation */
        .node-preview {
            position: absolute;
            min-width: 80px;
            min-height: 40px;
            background: #6366f1;
            border-radius: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
            opacity: 0.6;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            padding: 8px 16px;
            z-index: 1001;
            border: 2px dashed white;
        }

        .node-preview .node-text {
            color: white;
            font-weight: 600;
            font-size: 12px;
            text-align: center;
            white-space: nowrap;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
            pointer-events: none;
        }

        /* Preview connection styles */
        .connection-preview {
            pointer-events: none;
            opacity: 0.6;
            stroke-dasharray: 5, 5;
        }

        .color-picker-container {
            position: relative;
        }

        .color-palette {
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            background: var(--bg-surface);
            border-radius: 0.5rem;
            box-shadow: 0 10px 25px var(--shadow-color);
            border: 1px solid var(--border-color);
            padding: 0.5rem;
            display: none;
            gap: 0.25rem;
            flex-wrap: wrap;
            width: 196px;
            margin-bottom: 0.5rem;
            z-index: 100;
        }

        .color-palette.show {
            display: flex;
        }

        .color-option {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            cursor: pointer;
            border: 2px solid transparent;
            transition: all 0.2s;
        }

        .color-option:hover {
            transform: scale(1.1);
            border-color: #6b6b6b;
        }

        .color-option.selected {
            border-color: #1f1f1f;
            transform: scale(1.15);
        }

        .btn-color {
            background: var(--bg-surface);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
            position: relative;
        }

        .btn-color:hover {
            background: var(--bg-surface-alt);
        }

        /* Toggle Switch Styles */
        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 50px;
            height: 28px;
        }

        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: var(--border-color-strong);
            transition: .4s;
            border-radius: 28px;
        }

        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 22px;
            width: 22px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }

        input:checked+.toggle-slider {
            background-color: #3b82f6;
        }

        input:checked+.toggle-slider:before {
            transform: translateX(22px);
        }

        .toggle-group {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
        }

        .toggle-label-text {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-primary);
        }

        /* Slider Controls */
        .slider-group {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            margin-top: 0.75rem;
            padding: 0.75rem;
            background: color-mix(in srgb, var(--bg-surface-alt) 72%, transparent);
            border-radius: 0.5rem;
            border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
            transition: background-color 0.2s ease, border-color 0.2s ease;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
            overflow: hidden;
        }

        .slider-group:hover {
            background: var(--bg-surface-alt);
            border-color: var(--border-color);
        }

        .slider-control {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
        }

        .slider-control label {
            font-size: 0.75rem;
            font-weight: 500;
            color: var(--text-secondary);
            min-width: 50px;
            width: 50px;
            flex-shrink: 0;
        }

        .slider-control input[type="range"] {
            flex: 1;
            height: 16px;
            border-radius: 2px;
            outline: none;
            -webkit-appearance: none;
            appearance: none;
            position: relative;
            background: transparent;
        }

        .slider-control input[type="range"]::-webkit-slider-thumb {
            appearance: none;
            width: 16px;
            height: 16px;
            background: #3b82f6;
            border-radius: 50%;
            cursor: pointer;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            margin-top: -6px;
            transition: width 0.2s ease, height 0.2s ease, margin-top 0.2s ease;
        }

        .slider-control input[type="range"]::-moz-range-thumb {
            width: 16px;
            height: 16px;
            background: #3b82f6;
            border-radius: 50%;
            cursor: pointer;
            border: none;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            transition: width 0.2s ease, height 0.2s ease;
        }

        .slider-control input[type="range"]::-webkit-slider-track {
            height: 4px;
            background: var(--border-color-strong);
            border-radius: 2px;
        }

        .slider-control input[type="range"]::-moz-range-track {
            height: 4px;
            background: var(--border-color-strong);
            border-radius: 2px;
            border: none;
        }

        /* Progress track styling */
        .slider-control input[type="range"]::-webkit-slider-runnable-track {
            height: 4px;
            background: var(--border-color-strong);
            border-radius: 2px;
        }

        .slider-control input[type="range"]::-moz-range-progress {
            height: 4px;
            background: rgba(59, 130, 246, 0.2);
            border-radius: 2px;
            border: none;
        }

        .slider-control input[type="range"]::-webkit-slider-runnable-track {
            height: 4px;
            background: linear-gradient(to right, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.2) var(--progress, 0%), var(--border-color-strong) var(--progress, 0%), var(--border-color-strong) 100%);
            border-radius: 2px;
        }

        .slider-control input[type="number"] {
            width: 55px;
            max-width: 55px;
            min-width: 50px;
            padding: 0.375rem 0.5rem;
            border: 1px solid var(--border-color);
            border-radius: 0.25rem;
            font-size: 0.75rem;
            text-align: center;
            box-sizing: border-box;
            flex-shrink: 0;
            overflow: hidden;
            background: var(--bg-surface);
            color: var(--text-primary);
        }

        .slider-control input[type="number"]:focus {
            outline: none;
            border-color: #3b82f6;
        }

        .slider-group:hover .slider-control input[type="range"]::-webkit-slider-runnable-track {
            background: linear-gradient(to right, rgba(59, 130, 246, 0.32) 0%, rgba(59, 130, 246, 0.32) var(--progress, 0%), var(--border-color-strong) var(--progress, 0%), var(--border-color-strong) 100%);
        }

        .slider-group:hover .slider-control input[type="range"]::-moz-range-track {
            background: var(--border-color-strong);
        }

        .slider-group:hover .slider-control input[type="range"]::-moz-range-progress {
            background: rgba(59, 130, 246, 0.32);
        }

        .slider-control input[type="range"]::-webkit-slider-thumb:hover {
            width: 18px;
            height: 18px;
            margin-top: -7px;
        }

        .slider-control input[type="range"]::-moz-range-thumb:hover {
            width: 18px;
            height: 18px;
        }

        .slider-control input[type="range"]:active::-webkit-slider-thumb {
            width: 18px;
            height: 18px;
            margin-top: -7px;
        }

        .slider-control input[type="range"]:active::-moz-range-thumb {
            width: 18px;
            height: 18px;
        }

        .pattern-settings {
            margin-top: 0.75rem;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
            overflow: hidden;
        }

        .pattern-settings.show {
            display: block;
        }

        #dashSettings,
        #dotSettings {
            margin-bottom: 0.75rem;
        }

        #dashSettings:last-child,
        #dotSettings:last-child {
            margin-bottom: 0;
        }

        /* Export Buttons */
        .export-buttons {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            margin-bottom: 1rem;
        }

        .export-btn {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.875rem 1rem;
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            border-radius: 0.5rem;
            cursor: pointer;
            transition: all 0.2s ease;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-primary);
            width: 100%;
            text-align: left;
        }

        .export-btn:hover {
            background: var(--bg-surface-alt);
            border-color: var(--border-color-strong);
            transform: translateY(-1px);
            box-shadow: 0 2px 8px var(--shadow-color);
        }

        .export-btn:active {
            transform: translateY(0);
            box-shadow: 0 1px 4px var(--shadow-color);
        }

        .export-btn svg {
            flex-shrink: 0;
            stroke: var(--text-secondary);
            transition: stroke 0.2s ease;
        }

        .export-btn:hover svg {
            stroke: var(--text-primary);
        }

        .export-btn-png:hover {
            border-color: #3b82f6;
        }

        .export-btn-png:hover svg {
            stroke: #3b82f6;
        }

        .export-btn-svg:hover {
            border-color: #10b981;
        }

        .export-btn-svg:hover svg {
            stroke: #10b981;
        }

        .export-info {
            padding: 0.75rem;
            background: var(--bg-surface-alt);
            border-radius: 0.5rem;
            border: 1px solid var(--border-color);
        }

        .export-info p {
            font-size: 0.75rem;
            color: var(--text-secondary);
            margin: 0;
            line-height: 1.4;
        }

        .export-info p:not(:last-child) {
            margin-bottom: 0.5rem;
        }

        /* Sidebar Footer */
        .sidebar-footer {
            padding: 1rem 1.5rem;
            border-top: 1px solid var(--border-color);
            background: var(--bg-surface-alt);
            margin-top: auto;
        }

        .copyright-text {
            font-size: 0.75rem;
            color: var(--text-secondary);
            text-align: center;
            margin: 0;
        }

        .copyright-link {
            color: var(--text-secondary);
            text-decoration: none;
            transition: color 0.2s ease;
        }

        .copyright-link:hover {
            color: var(--text-primary);
            text-decoration: underline;
        }

        @media (max-width: 768px) {
            .sidebar {
                width: 100vw;
                right: -100vw;
            }

            .sidebar.open {
                right: 0;
            }

            .header.sidebar-open {
                right: 0;
            }

            .canvas-container.sidebar-open {
                padding-right: 0;
            }

            .canvas-container {
                padding-left: 56px;
            }

            .header {
                left: 0;
            }

            .minimap {
                right: 1rem;
                bottom: 1rem;
                width: 160px;
            }

            /* The mobile sidebar is a full-screen overlay, so there is nothing to shift out of. */
            .sidebar.open~.minimap {
                right: 1rem;
            }

            .minimap-body {
                height: 104px;
            }
        }

        /* Modal Styles */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(4px);
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
        }

        .modal-overlay.show {
            opacity: 1;
            visibility: visible;
        }

        .modal-dialog {
            background: var(--bg-surface);
            border-radius: 12px;
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            border: 1px solid var(--border-color);
            max-width: 500px;
            width: 90%;
            max-height: 80vh;
            overflow-y: auto;
            transform: scale(0.95) translateY(20px);
            transition: all 0.3s ease;
        }

        .modal-overlay.show .modal-dialog {
            transform: scale(1) translateY(0);
        }

        .modal-header {
            padding: 1.5rem 1.5rem 1rem 1.5rem;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .modal-title {
            font-size: 1.25rem;
            font-weight: bold;
            color: var(--text-primary);
            margin: 0;
        }

        .modal-close {
            background: none;
            border: none;
            color: var(--text-secondary);
            cursor: pointer;
            padding: 0.5rem;
            border-radius: 0.5rem;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .modal-close:hover {
            background: var(--bg-surface-alt);
            color: var(--text-primary);
        }

        .modal-body {
            padding: 1.5rem;
        }

        .modal-description {
            color: var(--text-secondary);
            line-height: 1.6;
            margin-bottom: 1.5rem;
        }

        .modal-features {
            margin-bottom: 1.5rem;
        }

        .modal-features h4 {
            color: var(--text-primary);
            font-size: 1rem;
            font-weight: 600;
            margin-bottom: 0.75rem;
        }

        .modal-features ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .modal-features li {
            color: var(--text-secondary);
            padding: 0.25rem 0;
            padding-left: 1.5rem;
            position: relative;
        }

        .modal-features li::before {
            content: "✓";
            position: absolute;
            left: 0;
            color: #10b981;
            font-weight: bold;
        }

        .modal-actions {
            display: flex;
            gap: 1rem;
            width: 100%;
        }

        .feedback-btn {
            background: transparent;
            color: var(--text-primary);
            border: 1px solid var(--border-color-strong);
            padding: 0.75rem 1.5rem;
            border-radius: 0.5rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            justify-content: center;
            flex: 1;
        }

        .feedback-btn:hover {
            background: var(--bg-surface-alt);
            border-color: var(--text-secondary);
            transform: translateY(-1px);
        }

        .feedback-btn:active {
            transform: translateY(0);
        }

        .discover-btn {
            flex: 1;
            background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
            color: white;
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 0.5rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            text-decoration: none;
            justify-content: center;
            width: 100%;
        }

        .discover-btn:hover {
            background: linear-gradient(135deg, #5855eb 0%, #7c3aed 100%);
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        }

        .discover-btn:active {
            transform: translateY(0);
        }

        /* EULA Section Styles */
        .modal-eula-section {
            margin-top: 1.5rem;
            border-top: 1px solid var(--border-color);
            padding-top: 1rem;
        }

        .eula-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.75rem 0;
            cursor: pointer;
            transition: all 0.2s ease;
            border-radius: 0.5rem;
        }

        .eula-header:hover {
            background: var(--bg-surface-alt);
            padding-left: 0.5rem;
            padding-right: 0.5rem;
        }

        .eula-title {
            font-size: 1rem;
            font-weight: 600;
            color: var(--text-primary);
            margin: 0;
        }

        .eula-toggle {
            width: 16px;
            height: 16px;
            stroke: var(--text-secondary);
            transition: transform 0.2s ease;
        }

        .eula-content {
            transition: all 0.3s ease;
            overflow: hidden;
        }

        .modal-eula-section.collapsed .eula-content {
            max-height: 0;
            opacity: 0;
        }

        .modal-eula-section.collapsed .eula-toggle {
            transform: rotate(-90deg);
        }

        .eula-text {
            padding: 1rem 0;
            color: var(--text-secondary);
            font-size: 0.875rem;
            line-height: 1.6;
        }

        .eula-text h4 {
            color: var(--text-primary);
            font-size: 1.1rem;
            font-weight: 600;
            margin: 0 0 1rem 0;
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 0.5rem;
        }

        .eula-text h5 {
            color: var(--text-primary);
            font-size: 0.95rem;
            font-weight: 600;
            margin: 1.5rem 0 0.5rem 0;
        }

        .eula-text p {
            margin: 0.75rem 0;
        }

        .eula-text ul {
            margin: 0.5rem 0;
            padding-left: 1.5rem;
        }

        .eula-text li {
            margin: 0.25rem 0;
        }

        .eula-footer {
            font-weight: 500;
            color: var(--text-primary);
            border-top: 1px solid var(--border-color);
            padding-top: 1rem;
            margin-top: 1.5rem;
            font-style: italic;
        }

        /* Note functionality styles */
        .btn-note {
            background: var(--bg-surface);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-note:hover {
            background: var(--bg-surface-alt);
        }

        .note-indicator {
            position: absolute;
            top: 2px;
            right: 2px;
            width: 8px;
            height: 8px;
            background: #f59e0b;
            border-radius: 50%;
            border: 1px solid white;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
            z-index: 5;
        }

        .note-modal {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }

        /* Blur app background when any modal is open (About or Note) */
        body.modal-blur> :not(.modal-overlay):not(.note-modal) {
            filter: blur(2px);
            transition: filter 0.15s ease;
        }

        /* App title hover interaction */
        .header .header-left h1 {
            cursor: pointer;
            transition: transform 0.15s ease, color 0.15s ease, text-underline-offset 0.15s ease;
        }

        .header .header-left h1:hover {
            text-decoration: underline;
            text-underline-offset: 2px;
            transform: translateY(-1px);
        }

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

        .note-modal-content {
            background: var(--bg-surface);
            border-radius: 12px;
            padding: 1.5rem;
            max-width: 500px;
            width: 90%;
            max-height: 80vh;
            overflow-y: auto;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
            border: 1px solid var(--border-color);
        }

        .note-modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }

        .note-modal-title {
            font-size: 1.25rem;
            font-weight: 600;
            color: var(--text-primary);
            margin: 0;
            padding: 4px 8px;
            border-radius: 6px;
            cursor: text;
            outline: none;
            max-width: calc(100% - 42px);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            border: 1px solid transparent;
            user-select: text;
            -webkit-user-select: text;
        }

        .note-modal-title:focus {
            border-color: #3b82f6;
            background: var(--bg-surface-alt);
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .note-modal-close {
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: var(--text-secondary);
            padding: 0;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }

        .note-modal-close:hover {
            background: var(--bg-surface-alt);
            color: var(--text-primary);
        }

        .note-textarea {
            width: 100%;
            min-height: 200px;
            padding: 1rem;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-family: system-ui, -apple-system, sans-serif;
            font-size: 0.875rem;
            line-height: 1.5;
            resize: vertical;
            background: var(--bg-surface-alt);
            color: var(--text-primary);
            box-sizing: border-box;
        }

        .note-textarea:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .note-textarea::placeholder {
            color: var(--text-secondary);
        }

        .note-modal-actions {
            display: flex;
            gap: 0.75rem;
            margin-top: 1.5rem;
            justify-content: flex-end;
        }

        .note-btn {
            padding: 0.75rem 1.5rem;
            border-radius: 6px;
            border: none;
            cursor: pointer;
            font-size: 0.875rem;
            font-weight: 500;
            transition: all 0.2s;
        }

        .note-btn-primary {
            background: #3b82f6;
            color: white;
        }

        .note-btn-primary:hover {
            background: #2563eb;
        }

        .note-btn-secondary {
            background: var(--bg-surface-alt);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .note-btn-secondary:hover {
            background: var(--bg-surface);
        }

        /* Left Toolbar Styles */
        .right-toolbar {
            position: fixed;
            top: 0;
            left: 0;
            width: 60px;
            height: 100vh;
            z-index: 85;
            display: flex;
            flex-direction: column;
            gap: 0;
            background: var(--bg-surface);
            border-right: 1px solid var(--border-color);
            box-shadow: 2px 0 10px var(--shadow-color);
            padding: 90px 0 1rem 0;
            align-items: center;
            pointer-events: auto;
        }

        .toolbar-btn {
            width: 44px;
            height: 44px;
            border-radius: 0.5rem;
            background: transparent;
            border: none;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-primary);
            position: relative;
            margin: 0.25rem 0;
            pointer-events: auto;
        }

        .toolbar-btn:hover {
            background: var(--bg-surface-alt);
            transform: scale(1.05);
        }

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

        .toolbar-btn .icon-mask {
            width: 20px;
            height: 20px;
        }

        .toolbar-btn-primary {
            background: transparent;
            color: var(--text-primary);
            margin: 0.5rem 0;
            border: 1px solid var(--border-color);
        }

        .toolbar-btn-primary:hover {
            background: var(--bg-surface-alt);
            border-color: var(--border-color-strong);
        }

        .toolbar-btn.active {
            background: transparent;
            color: var(--primary-color);
            border-color: var(--primary-color);
            box-shadow: inset 0 0 0 1px var(--primary-color);
        }

        .toolbar-btn.active:hover {
            background: rgba(59, 130, 246, 0.08);
            color: var(--primary-color-strong);
            border-color: var(--primary-color-strong);
            box-shadow: inset 0 0 0 1px var(--primary-color-strong);
        }

        .toolbar-btn.toolbar-action-flash {
            color: var(--primary-color);
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35), inset 0 0 0 1px var(--primary-color);
            animation: toolbarActionFlash 180ms ease-out;
        }

        @keyframes toolbarActionFlash {
            0% {
                box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.55), inset 0 0 0 1px var(--primary-color);
            }
            100% {
                box-shadow: 0 0 0 3px rgba(59, 130, 246, 0), inset 0 0 0 1px var(--primary-color);
            }
        }

        [data-theme="dark"] .toolbar-btn.active:hover {
            background: rgba(96, 165, 250, 0.15);
        }

        .draw-panel.show {
            display: flex;
        }

        .floating-panel-divider {
            width: 1px;
            align-self: stretch;
            background: var(--border-color);
            margin: 0 0.125rem;
            flex-shrink: 0;
        }

        .draw-stroke-thickness-control {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .draw-stroke-thickness-control .slider-control input[type="range"] {
            width: 120px;
        }

        .draw-stroke-thickness-control .slider-control input[type="number"] {
            width: 52px;
        }

        .draw-panel-label {
            font-size: 0.7rem;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.04em;
            margin: 0;
        }

        .draw-color-container {
            position: relative;
        }

        .draw-color-container .color-palette {
            width: 196px;
            left: 50%;
            bottom: 100%;
            transform: translateX(-50%);
        }

        .draw-thickness-control input[type="range"] {
            width: 140px;
        }

        .draw-thickness-control input[type="number"] {
            width: 60px;
        }

        /* ----- Minimap ----- */
        .minimap {
            position: fixed;
            right: 1.5rem;
            bottom: 1.5rem;
            width: 232px;
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            border-radius: 0.75rem;
            box-shadow: 0 10px 25px var(--shadow-color);
            z-index: 45;
            overflow: hidden;
            transition: right 0.3s ease;
        }

        .minimap[hidden] {
            display: none;
        }

        .sidebar.open~.minimap {
            right: calc(280px + 1.5rem);
        }

        .minimap-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.5rem;
            padding: 0.35rem 0.35rem 0.35rem 0.7rem;
        }

        .minimap-title {
            font-size: 0.7rem;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }

        .minimap-collapse-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 1.5rem;
            height: 1.5rem;
            padding: 0;
            border: none;
            border-radius: 0.375rem;
            background: transparent;
            color: var(--text-secondary);
            transition: background var(--animation-duration, 0.2s), color var(--animation-duration, 0.2s);
        }

        .minimap-collapse-btn svg {
            width: 14px;
            height: 14px;
            transition: transform var(--animation-duration, 0.2s);
        }

        .minimap-collapse-btn:hover {
            background: var(--bg-surface-alt);
            color: var(--text-primary);
        }

        .minimap.collapsed .minimap-collapse-btn svg {
            transform: rotate(180deg);
        }

        .minimap-body {
            position: relative;
            height: 150px;
            border-top: 1px solid var(--border-color);
            background: var(--bg-surface-alt);
            cursor: crosshair;
            touch-action: none;
            overflow: hidden;
        }

        .minimap-body:focus-visible {
            outline: 2px solid var(--primary-color);
            outline-offset: -2px;
        }

        .minimap-body.is-pointer-focus:focus-visible {
            outline: none;
        }

        .minimap.collapsed .minimap-body {
            display: none;
        }

        .minimap-canvas {
            display: block;
            width: 100%;
            height: 100%;
        }

        .minimap-viewport {
            position: absolute;
            top: 0;
            left: 0;
            border: 1.5px solid var(--primary-color);
            border-radius: 3px;
            background: rgba(59, 130, 246, 0.12);
            pointer-events: none;
            will-change: transform, width, height;
        }

        [data-theme="dark"] .minimap-viewport {
            background: rgba(96, 165, 250, 0.16);
        }

        .minimap-body.is-panning {
            cursor: grabbing;
        }

        .toolbar-spacer {
            margin-top: auto;
        }

        .toolbar-btn-history {
            border: 1px solid var(--border-color);
            margin: 0.25rem 0;
        }

        .toolbar-btn-history.is-disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        .toolbar-btn-history.is-disabled:hover {
            transform: none;
            background: transparent;
        }

        @media (max-width: 768px) {
            .right-toolbar {
                width: 56px;
                padding-top: 90px;
            }

            .toolbar-btn {
                width: 40px;
                height: 40px;
            }

            .toolbar-btn .icon-mask {
                width: 18px;
                height: 18px;
            }

            .canvas-container {
                padding-left: 56px;
            }

            .draw-panel {
                bottom: 1rem;
                padding: 0.45rem;
            }

            .draw-panel-label {
                display: none;
            }

            .draw-thickness-control input[type="range"] {
                width: 96px;
            }

            .draw-color-container .color-palette {
                width: 196px;
            }

            .header {
                left: 0;
            }
        }

        .note-btn-danger {
            background: #ef4444;
            color: white;
        }

        .note-btn-danger:hover {
            background: #dc2626;
        }

        /* Rich Text Editor Styles */
        .rich-text-editor {
            border: 1px solid var(--border-color);
            border-radius: 8px;
            background: var(--bg-surface-alt);
            color: var(--text-primary);
            overflow: hidden;
        }

        .formatting-toolbar {
            display: flex;
            gap: 0.25rem;
            padding: 0.5rem;
            background: var(--bg-surface);
            border-bottom: 1px solid var(--border-color);
            flex-wrap: wrap;
        }

        .format-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border: none;
            border-radius: 4px;
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.2s;
            font-size: 14px;
            font-weight: 500;
        }

        .format-btn:hover {
            background: var(--bg-surface-alt);
            color: var(--text-primary);
        }

        .format-btn.active {
            background: #3b82f6;
            color: white;
        }

        .format-btn svg {
            width: 16px;
            height: 16px;
        }

        .toolbar-separator {
            width: 1px;
            height: 24px;
            background: var(--border-color);
            margin: 4px 0.25rem;
        }

        .rich-text-content {
            min-height: 200px;
            padding: 1rem;
            font-family: system-ui, -apple-system, sans-serif;
            font-size: 0.875rem;
            line-height: 1.5;
            outline: none;
            box-sizing: border-box;
            overflow-y: auto;
            max-height: 400px;
        }

        .rich-text-content:focus {
            outline: none;
        }

        .rich-text-content p {
            margin: 0 0 1rem 0;
        }

        .rich-text-content p:last-child {
            margin-bottom: 0;
        }

        .rich-text-content ul,
        .rich-text-content ol {
            margin: 0 0 1rem 0;
            padding-left: 1.5rem;
        }

        .rich-text-content ul li,
        .rich-text-content ol li {
            margin: 0.25rem 0;
        }

        .rich-text-content ul {
            list-style-type: disc;
        }

        .rich-text-content ol {
            list-style-type: decimal;
        }

        .rich-text-content a {
            color: #3b82f6;
            text-decoration: underline;
        }

        .rich-text-content a:hover {
            color: #2563eb;
        }

        .rich-text-content strong {
            font-weight: 600;
        }

        .rich-text-content em {
            font-style: italic;
        }

        .rich-text-content u {
            text-decoration: underline;
        }

        .rich-text-content .todo-item {
            display: flex;
            align-items: flex-start;
            gap: 0.5rem;
            margin: 0.25rem 0;
        }

        .rich-text-content .todo-item:first-child {
            margin-top: 0;
        }

        .rich-text-content .todo-item:last-child {
            margin-bottom: 0;
        }

        .rich-text-content .todo-checkbox {
            margin-top: 0.125rem;
            cursor: pointer;
        }

        .rich-text-content .todo-text {
            flex: 1;
            min-height: 1.2em;
            outline: none;
        }

        .rich-text-content .todo-text.completed {
            text-decoration: line-through;
            color: var(--text-secondary);
        }

        .rich-text-content blockquote {
            border-left: 4px solid var(--border-color-strong);
            padding-left: 1rem;
            margin: 1rem 0;
            font-style: italic;
            color: var(--text-secondary);
        }

        .rich-text-content code {
            background: var(--bg-surface);
            padding: 0.125rem 0.25rem;
            border-radius: 4px;
            font-family: Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
            font-size: 0.8125rem;
        }

        .rich-text-content pre {
            background: var(--bg-surface);
            padding: 1rem;
            border-radius: 8px;
            overflow-x: auto;
            margin: 1rem 0;
        }

        .rich-text-content pre code {
            background: none;
            padding: 0;
        }

        .rich-text-content[contenteditable]:empty::before {
            content: attr(data-placeholder);
            color: var(--text-secondary);
            pointer-events: none;
            font-style: italic;
        }

        .rich-text-content img {
            max-width: 100%;
            height: auto;
            display: block;
            margin: 10px 0;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .rich-text-content img:hover {
            box-shadow: 0 4px 12px var(--shadow-color);
            transform: scale(1.02);
        }

        /* Image Fullscreen Overlay */
        .image-fullscreen-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.9);
            -webkit-backdrop-filter: blur(10px);
            backdrop-filter: blur(10px);
            z-index: 2000;
            display: none;
            justify-content: center;
            align-items: center;
            cursor: zoom-out;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .image-fullscreen-overlay.show {
            display: flex;
            opacity: 1;
        }

        .image-fullscreen-overlay img {
            max-width: 95%;
            max-height: 95%;
            object-fit: contain;
            box-shadow: 0 0 20px rgba(0,0,0,0.5);
            cursor: default;
            transform: scale(0.9);
            transition: transform 0.3s ease;
        }

        .image-fullscreen-overlay.show img {
            transform: scale(1);
        }

        .close-fullscreen-btn {
            position: absolute;
            top: 20px;
            right: 20px;
            background: rgba(255, 255, 255, 0.2);
            border: none;
            color: white;
            font-size: 30px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s;
            z-index: 2001;
        }

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

        .canvas-context-menu {
            position: fixed;
            display: none;
            min-width: 150px;
            background: var(--backdrop-blur);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            box-shadow: 0 10px 28px var(--shadow-color);
            backdrop-filter: blur(14px);
            -webkit-backdrop-filter: blur(14px);
            z-index: 3000;
            padding: 6px;
            user-select: none;
            -webkit-user-select: none;
        }

        .canvas-context-menu.show {
            display: block;
        }

        .canvas-context-menu-item {
            width: 100%;
            border: none;
            background: transparent;
            color: var(--text-primary);
            font-size: 13px;
            font-weight: 500;
            padding: 9px 10px;
            border-radius: 7px;
            cursor: pointer;
            transition: background 0.15s ease;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            text-align: left;
            user-select: none;
            -webkit-user-select: none;
        }

        .canvas-context-menu-item * {
            user-select: none;
            -webkit-user-select: none;
        }

        .canvas-context-menu-item:hover {
            background: var(--bg-secondary);
        }

        .canvas-context-menu-item:disabled {
            opacity: 0.45;
            cursor: default;
        }

        .canvas-context-menu-item:disabled:hover {
            background: transparent;
        }

        .canvas-context-menu-icon {
            width: 14px;
            height: 14px;
            background-color: var(--text-secondary);
            flex-shrink: 0;
            opacity: 0.9;
        }

        .canvas-context-menu-item:hover .canvas-context-menu-icon {
            background-color: var(--text-primary);
        }

        .context-menu-separator {
            height: 1px;
            background: var(--border-color);
            margin: 4px 4px;
        }

        .node.grouped.selected,
        .node.grouped.multi-selected {
            outline: 1.5px dashed rgba(167, 139, 250, 0.7);
            outline-offset: 4px;
        }

        /* Toast notifications (showToast in app.js) */
        .app-toast-container {
            position: fixed;
            left: 50%;
            bottom: 24px;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column-reverse;
            align-items: center;
            gap: 8px;
            z-index: 4100;
            pointer-events: none;
        }

        .app-toast {
            pointer-events: auto;
            max-width: min(90vw, 420px);
            padding: 12px 16px;
            border-radius: 10px;
            background: var(--bg-surface);
            color: var(--text-primary);
            border: 1px solid var(--border-color-strong);
            box-shadow: 0 8px 24px var(--shadow-color-strong);
            font-size: 13px;
            line-height: 1.4;
            cursor: pointer;
            opacity: 0;
            transform: translateY(8px);
            transition: opacity 0.2s ease, transform 0.2s ease;
        }

        .app-toast.show {
            opacity: 1;
            transform: translateY(0);
        }

        .app-toast-error {
            border-left: 3px solid #ef4444;
        }
