        /* Theme variables */
        :root {
            --bg: #f3f7f5;
            --text: #0b1b22;
            --surface: #ffffff;
            --surface-muted: #f0f4f2;
            --border: #d7e0d8;
            --primary: #189473;
            --primary-2: #2f8a64;
            --primary-hover: #217152;
            --muted: #5b6b7a;
            --link-stroke: rgba(27, 91, 67, 0.25);
            --tooltip-bg: rgba(11, 27, 22, 0.92);
            --tooltip-text: #f8fafc;
            --node-fill: #cfe9de;
            --node-selected: #e45858;
            --path-start: #22c55e; /* green */
            --path-end: #f59e0b;   /* amber */
            --grid-line: rgba(15, 23, 42, 0.04);
            --font-body: "Public Sans", "Source Sans 3", "Noto Sans", "Liberation Sans", sans-serif;
            --font-display: "Source Serif 4", "Libre Baskerville", "Noto Serif", "Georgia", serif;
            --app-cm-green: #007a5e;
            --app-cm-red: #ce1126;
            --app-cm-yellow: #fcd116;
            --sidebar-bg: linear-gradient(180deg, #1b5b43 0%, #217152 55%, #2f8a64 100%);
            --sidebar-text: rgba(255, 255, 255, 0.92);
            --sidebar-text-muted: rgba(255, 255, 255, 0.72);
            --sidebar-hover: rgba(255, 255, 255, 0.12);
        }

        [data-theme="dark"] {
            --bg: #0c1f18;
            --text: #e2f3ea;
            --surface: #0f241c;
            --surface-muted: #142c23;
            --border: #1f3a30;
            --primary: #4fd3a3;
            --primary-2: #7cd8b3;
            --primary-hover: #35bb8c;
            --muted: #9ab0a6;
            --link-stroke: rgba(143, 180, 160, 0.25);
            --tooltip-bg: rgba(12, 26, 20, 0.94);
            --tooltip-text: #e2f3ea;
            --node-fill: #1b3a2f;
            --node-selected: #f87171;
            --grid-line: rgba(255, 255, 255, 0.05);
        }
        /* General body styling */
        body {
            font-family: var(--font-body);
            margin: 0;
            padding: 0;
            background:
                radial-gradient(1200px 800px at 12% 0%, rgba(24, 148, 115, 0.16) 0%, transparent 55%),
                radial-gradient(1200px 800px at 90% 100%, rgba(35, 75, 125, 0.1) 0%, transparent 60%),
                repeating-linear-gradient(0deg, var(--grid-line) 0 1px, transparent 1px 36px),
                repeating-linear-gradient(90deg, var(--grid-line) 0 1px, transparent 1px 36px),
                var(--bg);
            color: var(--text);
        }

        /* Container for the page */
        .container {
            max-width: 1400px;
            margin: 18px auto;
            padding: 22px;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 247, 0.96));
            border: 1px solid var(--border);
            box-shadow: 0 16px 40px rgba(2, 6, 23, 0.12);
            border-radius: 18px;
        }

        .dbviz-page-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 1rem;
            margin-bottom: 1rem;
        }

        .dbviz-brand {
            display: inline-flex;
            align-items: center;
            gap: 0.9rem;
            min-width: 0;
        }

        .dbviz-brand-logo {
            width: 58px;
            height: 58px;
            object-fit: contain;
            flex: 0 0 auto;
            filter: drop-shadow(0 12px 24px rgba(2, 6, 23, 0.16));
        }

        .dbviz-brand-copy {
            display: flex;
            flex-direction: column;
            gap: 0.2rem;
            line-height: 1;
        }

        .dbviz-brand-name {
            font-family: var(--font-display);
            font-size: 1rem;
            font-weight: 700;
            letter-spacing: 0.18em;
            text-transform: uppercase;
            color: #1b5b43;
        }

        .dbviz-brand-module {
            font-size: 0.8rem;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--muted);
        }

        .dbviz-return-link {
            display: inline-flex;
            align-items: center;
            gap: 0.55rem;
            padding: 0.7rem 1rem;
            border-radius: 999px;
            border: 1px solid rgba(27, 91, 67, 0.14);
            background: rgba(27, 91, 67, 0.06);
            color: #1b5b43;
            font-weight: 700;
            text-decoration: none;
            white-space: nowrap;
            transition: background 140ms ease, transform 140ms ease;
        }

        .dbviz-return-link:hover {
            background: rgba(27, 91, 67, 0.12);
            color: #1b5b43;
        }

        .dbviz-heading {
            margin-bottom: 18px;
        }

        /* Header styling */
        h2 {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-family: var(--font-display);
            color: #1b5b43;
            font-size: 1.4rem;
            letter-spacing: 0.08em;
            margin-bottom: 6px;
            padding-left: 18px;
            position: relative;
            text-transform: uppercase;
        }

        h2::before {
            content: "";
            position: absolute;
            left: 0;
            top: 6px;
            bottom: 6px;
            width: 6px;
            border-radius: 999px;
            background: linear-gradient(
                180deg,
                var(--app-cm-green) 0%,
                var(--app-cm-green) 33%,
                var(--app-cm-red) 33%,
                var(--app-cm-red) 66%,
                var(--app-cm-yellow) 66%,
                var(--app-cm-yellow) 100%
            );
        }

        .subtitle {
            font-size: 0.9rem;
            color: var(--muted);
            margin: 0;
            max-width: 720px;
            padding-left: 18px;
        }

        @media (max-width: 767.98px) {
            .dbviz-page-header {
                flex-direction: column;
                align-items: stretch;
            }

            .dbviz-return-link {
                align-self: flex-start;
            }
        }

        /* Styling the input form for search */
        .input-form {
            position: absolute;
            top: 14px;
            left: 14px;
            z-index: 20;
            display: flex;
            flex-direction: column;
            align-items: stretch;
            gap: 8px;
            padding: 16px 16px 14px 20px;
            background:
                linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 38%),
                repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 10px),
                var(--sidebar-bg);
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 18px;
            color: var(--sidebar-text);
            --muted: var(--sidebar-text-muted);
            box-shadow: 0 18px 45px rgba(2, 6, 23, 0.25);
            width: 330px;
            max-height: calc(100% - 28px);
            overflow: auto;
            transition: transform 0.2s ease-in-out;
        }

        .input-form::before {
            content: "";
            position: absolute;
            top: 14px;
            bottom: 14px;
            left: 6px;
            width: 4px;
            border-radius: 999px;
            background: linear-gradient(
                180deg,
                var(--app-cm-green) 0%,
                var(--app-cm-green) 33%,
                var(--app-cm-red) 33%,
                var(--app-cm-red) 66%,
                var(--app-cm-yellow) 66%,
                var(--app-cm-yellow) 100%
            );
            opacity: 0.95;
            pointer-events: none;
        }

        .input-form.collapsed { transform: translateX(calc(-100% + 44px)); }
        .input-form .group-title {
            font-weight: 700;
            color: var(--sidebar-text-muted);
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.08em;
        }
        .input-form .group-title .bi { margin-right: 6px; }
        .input-form .divider {
            border-top: 1px solid rgba(255, 255, 255, 0.18);
            margin: 10px 8px;
        }
        .input-form .row { display: flex; gap: 10px; }
        .input-form .row > * { flex: 1; }
        .input-form .autocomplete-suggestions { width: 100%; }

        .sidebar-toggle {
            position: absolute;
            top: 8px;
            right: -16px;
            z-index: 21;
            width: 42px;
            height: 42px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.08);
            color: var(--sidebar-text);
            border: 1px solid rgba(255, 255, 255, 0.26);
            border-left: none;
            border-radius: 0 14px 14px 0;
            box-shadow: 0 12px 24px rgba(2, 6, 23, 0.24);
            cursor: pointer;
            transition: background 140ms ease, transform 140ms ease;
        }

        .sidebar-toggle:hover {
            background: rgba(255, 255, 255, 0.14);
        }

        .sidebar-toggle:active {
            transform: translateY(1px);
        }

        .badge {
            padding: 0.35rem 0.65rem;
            border-radius: 9999px;
            background: rgba(255, 255, 255, 0.12);
            border: 1px solid rgba(255, 255, 255, 0.3);
            color: var(--sidebar-text);
            font-size: 0.75rem;
            font-weight: 700;
            letter-spacing: 0.02em;
        }
        .legend { color: var(--muted); font-size: 0.85rem; }
        #legend { position: absolute; left: 12px; bottom: 56px; z-index: 11; }

        .input-form input, .input-form select {
            padding: 10px 12px;
            font-size: 0.95rem;
            margin-right: 0;
            border: 1px solid rgba(255, 255, 255, 0.28);
            border-radius: 14px;
            outline: none;
            transition: border 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
            background: rgba(255, 255, 255, 0.92);
            color: #0b1b22;
        }

        .input-form input:focus, .input-form select:focus {
            border: 1px solid var(--primary);
            box-shadow: 0 0 0 3px rgba(24, 148, 115, 0.22);
        }

        .input-form button {
            padding: 9px 12px;
            font-size: 0.9rem;
            border: 1px solid rgba(255, 255, 255, 0.26);
            background: rgba(255, 255, 255, 0.1);
            color: var(--sidebar-text);
            border-radius: 14px;
            cursor: pointer;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
            transition: background 140ms ease, transform 140ms ease, color 140ms ease, box-shadow 140ms ease;
            margin-right: 0;
            font-weight: 600;
            letter-spacing: 0.02em;
        }

        .input-form button:hover {
            background: var(--sidebar-hover);
            color: var(--sidebar-text);
            box-shadow: none;
            transform: translateY(-1px);
        }

        .input-form button:active {
            transform: translateY(0);
        }

        .input-form button:disabled {
            cursor: not-allowed;
            opacity: 0.55;
            box-shadow: none;
        }

        .input-form button:focus-visible {
            outline: none;
            box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
        }

        /* Graph container */
        #graph {
            width: 100%;
            height: 600px;
            border: 1px solid var(--border);
            border-radius: 16px;
            background-color: var(--surface);
            background-image:
                linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
                linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
            background-size: 32px 32px;
            box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04), 0 18px 36px rgba(2, 6, 23, 0.12);
            overflow: visible;  /* Ensure no clipping happens */
            position: relative;
        }

        /* Tooltip styling */
        .tooltip {
            position: absolute;
            text-align: center;
            width: auto;
            height: auto;
            padding: 8px;
            font: 14px var(--font-body);
            background: var(--tooltip-bg);
            color: var(--tooltip-text);
            border-radius: 6px;
            pointer-events: none;
            opacity: 0;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        /* Autocomplete suggestions */
        .autocomplete { position: relative; display: inline-block; }
        .autocomplete-suggestions {
            position: absolute;
            top: calc(100% + 4px);
            left: 0;
            z-index: 999;
            background-color: var(--surface);
            border: 1px solid var(--border);
            border-radius: 8px;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
            max-height: 240px;
            overflow-y: auto;
            width: 300px;
        }

        .autocomplete-suggestion {
            padding: 10px;
            cursor: pointer;
            font-size: 1rem;
        }

        .autocomplete-suggestion:hover {
            background-color: var(--surface-muted);
        }

        /* Node and link styling */
        .node circle {
            cursor: pointer;
            stroke-width: 1.5px;
            transition: transform 0.15s ease, filter 0.2s ease, stroke 0.2s ease;
            filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
            stroke: rgba(0,0,0,0.15);
        }

        .node circle:hover {
            stroke: var(--primary);
            stroke-width: 3px;
            transform: translateY(-1px) scale(1.02);
        }

        .link {
            fill: none;
            stroke: var(--link-stroke);
            stroke-width: 2px;
        }

        .node circle { fill: var(--node-fill); }
        .selected { fill: var(--node-selected); filter: url(#glow); }

        /* Node marking colors */
        .marked-red { fill: #ef4444 !important; }
        .marked-blue { fill: #3b82f6 !important; }
        .marked-green { fill: #22c55e !important; }
        .marked-yellow { fill: #eab308 !important; }
        .marked-purple { fill: #a855f7 !important; }
        .marked-pink { fill: #ec4899 !important; }
        .marked-orange { fill: #f97316 !important; }
        .marked-teal { fill: #14b8a6 !important; }
        
        /* Marking mode indicator */
        .marking-active {
            cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="%23ef4444" stroke="white" stroke-width="2"/></svg>'), auto !important;
        }
        /* Ensure node cursor does not override marking cursor */
        .marking-active .node circle { cursor: inherit !important; }
        
        .color-picker {
            display: flex;
            gap: 4px;
            margin: 4px 0;
        }
        
        .color-option {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            cursor: pointer;
            border: 2px solid transparent;
            transition: all 0.2s ease;
        }
        
        .color-option:hover {
            transform: scale(1.1);
            border-color: white;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        }
        
        .color-option.active {
            border-color: white;
            box-shadow: 0 0 0 2px var(--primary);
        }

        /* Path highlighting */
        .path-node circle {
            stroke: var(--primary);
            stroke-width: 3px;
            filter: drop-shadow(0 0 6px rgba(24, 148, 115, 0.45));
        }
        .path-link {
            stroke: var(--primary);
            stroke-width: 3px;
            filter: drop-shadow(0 0 6px rgba(24, 148, 115, 0.45));
        }
        .path-start circle { fill: var(--path-start) !important; }
        .path-end circle { fill: var(--path-end) !important; }

        /* Multi-select mode indicators */
        .multi-select-active {
            cursor: crosshair !important;
        }
        
        .multi-select-node circle {
            stroke: #f59e0b;
            stroke-width: 2px;
            stroke-dasharray: 4, 2;
            animation: dashRotate 2s linear infinite;
        }
        
        @keyframes dashRotate {
            to { stroke-dashoffset: -12; }
        }
        
        .multi-select-indicator {
            position: absolute;
            top: -8px;
            right: -8px;
            width: 20px;
            height: 20px;
            background: linear-gradient(135deg, #f59e0b, #d97706);
            border-radius: 50%;
            color: white;
            font-size: 11px;
            font-weight: 700;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
            z-index: 5;
        }

        .tooltip {
            position: absolute;
            text-align: left;
            padding: 15px;
            font: 14px var(--font-body);
            background: var(--tooltip-bg);
            color: var(--tooltip-text);
            border-radius: 12px;
            pointer-events: auto;
            opacity: 0;
            box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
            backdrop-filter: blur(10px);
            transition: opacity 0.2s ease-in-out;
            max-height: 250px;
            overflow-y: auto;
        }

        /* Loading overlay */
        #loading-overlay {
            position: absolute;
            inset: 0;
            background: rgba(11, 27, 22, 0.35);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 10;
            border-radius: 16px;
        }
        .spinner {
            width: 36px;
            height: 36px;
            border: 4px solid rgba(255,255,255,0.3);
            border-top-color: white;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }
        @keyframes spin { to { transform: rotate(360deg); } }

        /* Query loader */
        #query-loading {
            position: absolute;
            inset: 0;
            background: rgba(11, 27, 22, 0.4);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 20;
            border-radius: 16px;
            gap: 12px;
            color: #fff;
            font-weight: 600;
        }
        #query-loading .label { text-shadow: 0 1px 2px rgba(0,0,0,0.4); }

        /* Modal polish */
        .sql-block {
            white-space: pre-wrap;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
            font-size: 13px;
            line-height: 1.6;
            background: linear-gradient(135deg, #0b1220, #0f1629);
            color: #e5e7eb;
            padding: 20px;
            border-radius: 12px;
            border: 1px solid rgba(24, 148, 115, 0.2);
            box-shadow: 
                inset 0 1px 0 rgba(255,255,255,0.06),
                0 4px 20px rgba(0,0,0,0.3);
            position: relative;
            overflow: auto;
            max-height: 400px;
        }
        
        .sql-block::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 2px;
            background: linear-gradient(90deg, var(--primary), var(--primary-2));
            border-radius: 12px 12px 0 0;
        }

        /* SQL Editor Styles */
        .sql-editor {
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
            font-size: 13px;
            line-height: 1.6;
            background: linear-gradient(135deg, #0b1220, #0f1629);
            color: #e5e7eb;
            padding: 20px;
            border-radius: 12px;
            border: 1px solid rgba(24, 148, 115, 0.2);
            box-shadow: 
                inset 0 1px 0 rgba(255,255,255,0.06),
                0 4px 20px rgba(0,0,0,0.3);
            position: relative;
            overflow: auto;
            max-height: 400px;
            min-height: 200px;
            resize: vertical;
            outline: none;
            width: 100%;
            box-sizing: border-box;
        }

        .sql-editor:focus {
            border-color: rgba(24, 148, 115, 0.4);
            box-shadow: 
                inset 0 1px 0 rgba(255,255,255,0.06),
                0 4px 20px rgba(0,0,0,0.3),
                0 0 0 3px rgba(24, 148, 115, 0.1);
        }

        .edit-mode-actions {
            display: flex;
            gap: 8px;
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px solid rgba(24, 148, 115, 0.1);
        }

        .edit-mode-actions button {
            padding: 6px 12px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.1);
            color: var(--text);
            border-radius: 8px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s ease;
        }

        .edit-mode-actions button:hover {
            background: rgba(255, 255, 255, 0.15);
            border-color: rgba(255, 255, 255, 0.3);
        }

        .edit-mode-actions .save-btn {
            background: linear-gradient(135deg, #22c55e, #16a34a);
            border-color: #22c55e;
            color: white;
        }

        .edit-mode-actions .save-btn:hover {
            background: linear-gradient(135deg, #16a34a, #15803d);
        }
        .badge-pill {
            display: inline-block;
            padding: 2px 8px;
            font-size: 11px;
            border-radius: 9999px;
            background: rgba(255,255,255,0.08);
            color: #e5e7eb;
            border: 1px solid rgba(255,255,255,0.12);
        }

        /* Copy success toast */
        .copy-toast {
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 60;
            background: var(--primary);
            color: white;
            padding: 12px 16px;
            border-radius: 10px;
            box-shadow: 0 8px 20px rgba(24, 148, 115, 0.35);
            transform: translateX(100%);
            transition: transform 0.2s ease-in-out;
            font-size: 14px;
            font-weight: 600;
        }
        .copy-toast.show { transform: translateX(0); }

        /* Minimap */
        #minimap {
            position: absolute;
            bottom: 60px;
            right: 12px;
            width: 150px;
            height: 100px;
            background: rgba(255, 255, 255, 0.92);
            border: 1px solid var(--border);
            border-radius: 8px;
            z-index: 12;
            overflow: hidden;
            backdrop-filter: blur(6px);
            cursor: move;
            transition: box-shadow 0.2s ease;
        }
        
        #minimap:hover {
            box-shadow: 0 8px 18px rgba(2, 6, 23, 0.16);
        }
        
        #minimap.dragging {
            box-shadow: 0 12px 26px rgba(2, 6, 23, 0.22);
            transform: scale(1.05);
        }
        
        #minimap svg {
            width: 100%;
            height: 100%;
            pointer-events: none;
        }
        
        .minimap-viewport {
            fill: rgba(24, 148, 115, 0.15);
            stroke: var(--primary);
            stroke-width: 2;
            cursor: pointer;
            pointer-events: all;
        }
        
        .minimap-viewport:hover {
            fill: rgba(24, 148, 115, 0.25);
        }
        
        .minimap-node {
            cursor: pointer;
            pointer-events: all;
        }
        
        .minimap-node:hover {
            stroke: var(--primary);
            stroke-width: 1;
        }

        /* Keyboard shortcuts panel */
        #shortcuts-panel {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 20px;
            z-index: 100;
            display: none;
            max-width: 400px;
            box-shadow: 0 20px 60px rgba(2, 6, 23, 0.22);
            backdrop-filter: blur(20px);
        }

        .shortcut-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 0;
            border-bottom: 1px solid rgba(15, 23, 42, 0.08);
        }

        .shortcut-key {
            background: var(--surface-muted);
            padding: 4px 8px;
            border-radius: 4px;
            font-family: monospace;
            font-size: 12px;
            color: var(--text);
        }

        /* Export menu */
        #export-menu {
            position: absolute;
            top: 100%;
            left: 0;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 8px;
            box-shadow: 0 8px 20px rgba(2, 6, 23, 0.18);
            z-index: 20;
            display: none;
            min-width: 150px;
        }

        .export-item {
            padding: 10px 15px;
            cursor: pointer;
            border-bottom: 1px solid var(--border);
            font-size: 13px;
        }

        .export-item:hover {
            background: rgba(24, 148, 115, 0.08);
        }

        .export-item:last-child {
            border-bottom: none;
        }

        /* Performance indicator */
        #perf-indicator {
            position: absolute;
            top: 12px;
            right: 12px;
            background: rgba(11, 27, 22, 0.75);
            color: var(--tooltip-text);
            padding: 4px 8px;
            border-radius: 6px;
            font-size: 11px;
            font-family: monospace;
            z-index: 15;
            display: none;
        }

        /* Quick actions floating button */
        #quick-actions {
            position: absolute;
            bottom: 12px;
            left: 180px;
            z-index: 13;
        }

        .quick-action-btn {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--surface);
            border: 1px solid var(--border);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 8px;
            box-shadow: 0 8px 18px rgba(2, 6, 23, 0.16);
            transition: all 0.2s ease;
        }

        .quick-action-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 12px 24px rgba(2, 6, 23, 0.2);
            background: rgba(24, 148, 115, 0.08);
        }

        /* Remove edge mode */
        .remove-edge-active .link { cursor: crosshair; }
        .remove-edge-active .link:hover { stroke: #ef4444; stroke-width: 3px; }

        /* Enhanced Modal Styles */
        #modal-backdrop {
            backdrop-filter: blur(8px);
            animation: fadeIn 0.2s ease-out;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        
        @keyframes modalSlideIn {
            from { 
                opacity: 0; 
                transform: translateY(-20px) scale(0.95); 
            }
            to { 
                opacity: 1; 
                transform: translateY(0) scale(1); 
            }
        }
        
        .modal-content {
            animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
            backdrop-filter: blur(20px);
            background: rgba(255, 255, 255, 0.95) !important;
            border: 1px solid rgba(255, 255, 255, 0.2) !important;
        }
        
        [data-theme="dark"] .modal-content {
            background: rgba(15, 23, 42, 0.95) !important;
            border: 1px solid rgba(31, 41, 55, 0.6) !important;
        }
        
        .modal-header {
            background: linear-gradient(135deg, 
                rgba(24, 148, 115, 0.08), 
                rgba(47, 138, 100, 0.08));
            border-bottom: 1px solid rgba(24, 148, 115, 0.15) !important;
        }
        
        .modal-header .modal-title {
            background: linear-gradient(135deg, var(--primary), var(--primary-2));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            font-weight: 800;
            font-size: 18px;
        }
        
        #modal-close {
            transition: all 0.2s ease;
            background: rgba(255, 255, 255, 0.1) !important;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2) !important;
        }
        
        #modal-close:hover {
            background: rgba(239, 68, 68, 0.1) !important;
            border-color: rgba(239, 68, 68, 0.3) !important;
            color: #ef4444 !important;
            transform: scale(1.05);
        }
        
        .modal-actions {
            background: linear-gradient(135deg, 
                rgba(24, 148, 115, 0.03), 
                rgba(47, 138, 100, 0.03));
            border-top: 1px solid rgba(24, 148, 115, 0.1) !important;
        }
        
        .modal-actions button {
            transition: all 0.2s ease;
            font-weight: 600;
        }
        
        #copy-sql {
            background: linear-gradient(135deg, var(--primary), var(--primary-2)) !important;
            box-shadow: 0 8px 25px rgba(24, 148, 115, 0.4) !important;
            transform: translateY(0);
            transition: all 0.2s ease;
        }
        
        #copy-sql:hover {
            transform: translateY(-2px);
            box-shadow: 0 12px 35px rgba(24, 148, 115, 0.5) !important;
        }
        
        #close-modal {
            background: rgba(255, 255, 255, 0.1) !important;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2) !important;
        }
        
        #close-modal:hover {
            background: rgba(255, 255, 255, 0.15) !important;
            border-color: rgba(255, 255, 255, 0.3) !important;
            transform: translateY(-1px);
        }

        /* Map-like controls */
        #map-controls {
            position: absolute;
            right: 12px;
            bottom: 12px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            z-index: 11;
        }
        .control-group {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 12px;
            box-shadow: 0 8px 18px rgba(2, 6, 23, 0.14);
            overflow: hidden;
        }
        .control-group button {
            display: block;
            background: transparent;
            color: var(--text);
            border: none;
            width: 38px;
            height: 38px;
            cursor: pointer;
        }
        .control-group button + button { border-top: 1px solid var(--border); }
        .control-group button:hover { background: rgba(24, 148, 115, 0.08); }

        /* Scale bar */
        #scale-bar {
            position: absolute;
            left: 12px;
            bottom: 12px;
            z-index: 11;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            color: var(--text);
            font-size: 12px;
        }
        #scale-bar .bar {
            height: 6px;
            background: var(--primary);
            border-radius: 3px;
            width: 100px; /* initial, updated via JS */
        }

        .tooltip hr {
            border: 0;
            height: 1px;
            background: rgba(255, 255, 255, 0.18); /* Slightly lighter line */
            margin: 10px 0;
        }

        #close-tooltip {
            align-self: flex-end;
            background-color: var(--app-cm-red);
            color: white;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            padding: 5px;
            font-size: 12px;
            width: 24px;
            height: 24px;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: background-color 0.2s ease;
        }

        #close-tooltip:hover {
            background-color: #b10f20;
        }

        .tooltip label {
            display: flex;
            align-items: center;
            margin: 5px 0;
            padding: 0;
        }

        .tooltip input[type="checkbox"] {
            margin-right: 8px;
        }

        .tooltip .tooltip-title {
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 5px;
        }

        .tooltip .tooltip-records {
            color: var(--app-cm-yellow);
            font-size: 13px;
            margin-bottom: 5px;
        }

        .tooltip-icon {
            margin-right: 8px;
            width: 16px;
            height: 16px;
        }

        /* Responsive */
        @media (max-width: 768px) {
            .input-form {
                flex-direction: column;
                align-items: center;
            }

            .input-form input, .input-form select, .input-form button {
                margin: 10px 0;
                width: 100%;
                max-width: 300px;
            }
        }

/* Refactor: extracted template class hooks */
.divider-compact {
    margin: 8px 0;
}

.quick-path-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.quick-path-input {
    font-size: 12px;
}

.quick-path-apply {
    font-size: 12px;
    padding: 8px 10px;
}

.path-badge {
    align-self: center;
    font-size: 11px;
}

.badge-inline {
    align-self: center;
}

.export-wrap {
    position: relative;
    width: 100%;
}

.export-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    color: var(--text);
}

.color-option {
    border: 0;
    padding: 0;
    background: transparent;
}

.color-option[data-color="red"] { background: #ef4444; }
.color-option[data-color="blue"] { background: #3b82f6; }
.color-option[data-color="green"] { background: #22c55e; }
.color-option[data-color="yellow"] { background: #eab308; }
.color-option[data-color="purple"] { background: #a855f7; }
.color-option[data-color="pink"] { background: #ec4899; }
.color-option[data-color="orange"] { background: #f97316; }
.color-option[data-color="teal"] { background: #14b8a6; }

#shortcuts-panel .shortcuts-title {
    margin-top: 0;
    color: var(--primary);
}

#shortcuts-panel .shortcuts-actions {
    margin-top: 15px;
    text-align: center;
}

#shortcuts-panel .shortcuts-close-btn {
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

#modal-backdrop .dbviz-modal-content {
    color: var(--text);
    width: min(1000px, 94vw);
    max-height: 88vh;
    border-radius: 16px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#modal-backdrop .dbviz-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.dbviz-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dbviz-modal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.dbviz-sql-meta {
    background: rgba(24, 148, 115, 0.1);
    color: var(--primary);
    border: 1px solid rgba(24, 148, 115, 0.2);
}

#modal-close.dbviz-modal-close {
    color: var(--text);
    border-radius: 12px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

#modal-body.dbviz-modal-body {
    padding: 0 20px 16px;
    overflow: auto;
    flex: 1;
}

.modal-actions.dbviz-modal-actions {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    justify-content: space-between;
    align-items: center;
}

.dbviz-modal-tip {
    color: var(--muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dbviz-modal-tip-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--muted);
}

.dbviz-modal-buttons {
    display: flex;
    gap: 8px;
}

.dbviz-action-btn {
    padding: 10px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dbviz-action-btn-secondary {
    border: 1px solid rgba(24, 148, 115, 0.3);
    background: rgba(24, 148, 115, 0.1);
    color: var(--primary);
}

.dbviz-action-btn-primary {
    border: 0;
    color: #fff;
}

.dbviz-action-btn-ghost {
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
}
