        /* The hidden attribute always hides, even on elements styled display:flex etc. */
        [hidden] { display: none !important; }
        :root {
            --bg-primary: #ffffff; --bg-secondary: #f8f9fa; --bg-tertiary: #e9ecef; --bg-elevated: #dee2e6;
            --border-color: #ced4da; --border-focus: #6366f1;
            --text-primary: #212529; --text-secondary: #495057; --text-muted: #6c757d;
            --accent-primary: #4f46e5; --accent-secondary: #6366f1; --accent-tertiary: #818cf8;
            --success: #34d399; --warning: #fbbf24; --danger: #f87171;
            --canvas-bg: #f5f5f7; --canvas-grid: #e5e5e7;
        }
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: 'DM Sans', -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
        .menubar { background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 12px; height: 36px; gap: 4px; }
        .menubar-logo { display: flex; align-items: center; gap: 8px; margin-right: 16px; padding-right: 16px; border-right: 1px solid var(--border-color); }
        .menubar-logo svg { width: 24px; height: 24px; }
        .menubar-logo span { font-weight: 600; font-size: 15px; background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
        .menu-item { position: relative; padding: 6px 12px; font-size: 13px; color: var(--text-secondary); cursor: pointer; border-radius: 4px; transition: all 0.15s; }
        .menu-item:hover, .menu-item:focus, .menu-item[aria-expanded="true"] { background: var(--bg-tertiary); color: var(--text-primary); outline: none; }
        .menu-dropdown { position: absolute; top: 100%; left: 0; margin-top: 4px; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 8px; min-width: 220px; width: max-content; max-width: min(360px, calc(100vw - 16px)); padding: 6px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); z-index: 1000; display: none; animation: dropdownIn 0.15s; }
        @keyframes dropdownIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
        .menu-item[aria-expanded="true"] .menu-dropdown { display: block; }
        .dropdown-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; font-size: 13px; color: var(--text-secondary); cursor: pointer; border-radius: 4px; transition: all 0.1s; }
        .dropdown-item:hover { background: var(--accent-tertiary); color: var(--text-primary); }
        .dropdown-item.selected { background: var(--accent-tertiary); color: var(--accent-primary); font-weight: 500; }
        .dropdown-item[style*="width:"].selected { outline: 2px solid var(--accent-primary); outline-offset: -2px; }
        .dropdown-item svg { width: 16px; height: 16px; margin-right: 10px; flex-shrink: 0; }
        .dropdown-item-content { display: flex; align-items: center; white-space: nowrap; }
        .dropdown-shortcut { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; margin-left: auto; padding-left: 24px; white-space: nowrap; }
        .dropdown-divider { height: 1px; background: var(--border-color); margin: 6px 0; }
        .dropdown-submenu { position: relative; }
        .dropdown-submenu > .dropdown-item-content::after { content: '▸'; margin-left: auto; padding-left: 12px; }
        .dropdown-submenu-content { position: absolute; left: 100%; top: 0; min-width: 180px; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); padding: 6px; display: none; }
        .dropdown-submenu:hover > .dropdown-submenu-content { display: block; animation: dropdownIn 0.15s; }
        .dropdown-submenu.open > .dropdown-submenu-content { display: block; }
        .menubar .dropdown-item:focus { background: var(--accent-tertiary); color: var(--text-primary); outline: 2px solid var(--accent-primary); outline-offset: -2px; }
        .ribbon-dropdown { position: relative; }
        .ribbon-dropdown-btn { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); font-size: 13px; font-family: inherit; cursor: pointer; min-width: 130px; }
        .ribbon-dropdown-btn:hover { border-color: var(--accent-primary); }
        .ribbon-dropdown-menu { position: absolute; top: 100%; left: 0; margin-top: 4px; min-width: 180px; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); padding: 6px; display: none; z-index: 1000; }
        .ribbon-dropdown.active .ribbon-dropdown-menu { display: block; animation: dropdownIn 0.15s; }
        .ribbon-dropdown.active #layoutDropdownMenu { display: flex; flex-wrap: wrap; gap: 3px; }
        #layoutDropdownMenu .dropdown-item { width: 48px !important; height: 48px !important; }
        #layoutDropdownMenu .dropdown-item svg { min-width: 42px; min-height: 42px; margin-right: 0 !important; }
        .ribbon-dropdown.active #textAlignDropdownMenu { display: flex; flex-wrap: wrap; gap: 3px; }
        #textAlignDropdownMenu .dropdown-item { display: flex !important; align-items: center !important; justify-content: center !important; padding: 0 !important; }
        #textAlignDropdownMenu .dropdown-item svg { min-width: 28px; min-height: 28px; margin-right: 0 !important; }
        .ribbon-dropdown.active #iconPosDropdownMenu { display: flex; flex-wrap: wrap; gap: 3px; }
        #iconPosDropdownMenu .dropdown-item { display: flex !important; align-items: center !important; justify-content: center !important; padding: 0 !important; }
        #iconPosDropdownMenu .dropdown-item svg { min-width: 28px; min-height: 28px; margin-right: 0 !important; }
        .ribbon-dropdown.active #linkStyleDropdownMenu { display: flex; flex-wrap: wrap; gap: 3px; }
        #linkStyleDropdownMenu .dropdown-item { display: flex !important; align-items: center !important; justify-content: center !important; padding: 0 !important; }
        #linkStyleDropdownMenu .dropdown-item svg { min-width: 28px; min-height: 28px; margin-right: 0 !important; }
        .ribbon-dropdown.active #linkRouteDropdownMenu { display: flex; flex-wrap: wrap; gap: 3px; }
        #linkRouteDropdownMenu .dropdown-item { display: flex !important; align-items: center !important; justify-content: center !important; padding: 0 !important; }
        #linkRouteDropdownMenu .dropdown-item svg { min-width: 28px; min-height: 28px; margin-right: 0 !important; }
        .ribbon-dropdown.active #linkEndDropdownMenu { display: flex; flex-wrap: wrap; gap: 3px; }
        #linkEndDropdownMenu .dropdown-item { display: flex !important; align-items: center !important; justify-content: center !important; padding: 0 !important; }
        #linkEndDropdownMenu .dropdown-item svg { min-width: 28px; min-height: 28px; margin-right: 0 !important; }
        .ribbon-group.disabled { opacity: 0.4; pointer-events: none; }
        .ribbon-submenu { left: 100%; top: -6px; min-width: 140px; }
        .ribbon-wrapper { background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }
        .ribbon-wrapper::-webkit-scrollbar { height: 6px; }
        .ribbon-wrapper::-webkit-scrollbar:vertical { display: none; }
        .ribbon-wrapper::-webkit-scrollbar-track { background: transparent; }
        .ribbon-wrapper::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
        .ribbon-wrapper::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
        .ribbon { padding: 3px 4px 2px; display: flex; align-items: stretch; gap: 6px; flex-wrap: nowrap; width: max-content; min-width: 100%; }
        .ribbon-dropdown-menu { position: fixed; z-index: 3000; }
        .ribbon-group { display: flex; flex-direction: column; align-items: center; gap: 1px; padding-right: 6px; border-right: 1px solid var(--border-color); flex-shrink: 0; position: relative; }
        .ribbon-group:last-child { border-right: none; }
        .ribbon-group-content { display: flex; align-items: center; gap: 4px; flex: 1; }
        .ribbon-group-label { font-size: 9px; letter-spacing: 0.02em; color: var(--text-muted); text-align: center; margin-top: -2px; }
        .ribbon-btn { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: transparent; border: 1px solid transparent; border-radius: 4px; cursor: pointer; color: var(--text-secondary); transition: all 0.15s; }
        .ribbon-btn:hover:not(:disabled) { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-color); }
        .ribbon-btn:active:not(:disabled) { transform: scale(0.95); }
        .ribbon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
        .ribbon-btn svg { width: 16px; height: 16px; }
        .ribbon-btn[aria-pressed="true"] { background: var(--accent-tertiary); color: var(--text-primary); border-color: var(--accent-secondary); }
        .ribbon-checkbox { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 11px; color: var(--text-secondary); user-select: none; }
        .ribbon-checkbox input[type="checkbox"] { display: none; }
        .ribbon-checkbox .checkbox-box { width: 14px; height: 14px; border: 1.5px solid var(--border-color); border-radius: 3px; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); transition: all 0.15s ease; }
        .ribbon-checkbox input[type="checkbox"]:checked + .checkbox-box { background: var(--accent-primary); border-color: var(--accent-primary); }
        .ribbon-checkbox input[type="checkbox"]:checked + .checkbox-box svg { opacity: 1; }
        .ribbon-checkbox .checkbox-box svg { width: 10px; height: 10px; stroke: white; stroke-width: 3; fill: none; opacity: 0; transition: opacity 0.15s ease; }
        .ribbon-checkbox:hover .checkbox-box { border-color: var(--accent-secondary); }
        .ribbon-checkbox input[type="checkbox"]:disabled + .checkbox-box { opacity: 0.5; cursor: not-allowed; }
        .ribbon-checkbox.disabled { opacity: 0.5; cursor: not-allowed; }
        .ribbon-btn.recording { animation: pulse-record 1s infinite; }
        .ribbon-btn.paste-btn { width: 44px; height: 44px; }
        .ribbon-btn.paste-btn svg { width: 28px; height: 28px; }
        .ribbon-btn.small-btn { width: 20px; height: 20px; }
        .ribbon-btn.small-btn svg { width: 12px; height: 12px; }
        @keyframes pulse-record { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
        .audio-btn { width: 32px; height: 32px; }
        .audio-btn svg { width: 22px; height: 22px; }
        .node-audio-controls { position: absolute; z-index: 100; display: flex; gap: 3px; }
        .node-audio-btn { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 50%; cursor: pointer; color: var(--text-secondary); padding: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
        .node-audio-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
        .node-audio-btn.node-audio-delete:hover { color: var(--danger); }
        .node-audio-btn svg { width: 14px; height: 14px; }
        .ribbon-select { height: 28px; padding: 0 8px; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-primary); font-size: 12px; font-family: inherit; cursor: pointer; min-width: 90px; }
        .ribbon-select:focus { outline: none; border-color: var(--border-focus); }
        .color-swatch { width: 24px; height: 24px; border-radius: 4px; border: 2px solid var(--border-color); cursor: pointer; transition: all 0.15s; }
        .color-swatch:hover { transform: scale(1.1); border-color: var(--accent-primary); }
        .color-input { position: absolute; opacity: 0; width: 24px; height: 24px; cursor: pointer; }
        .main-container { display: flex; flex: 1; overflow: hidden; }
        .shapes-panel { width: 140px; min-width: 120px; max-width: 200px; background: var(--bg-secondary); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; transition: none; overflow: hidden; position: relative; }
        .shapes-panel.collapsed { width: 0; min-width: 0; border-right: none; }
        .shapes-panel-header { padding: 8px; text-align: center; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
        .shapes-panel-header h3 { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
        .shapes-section { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 60px; }
        .shapes-grid { flex: 1; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; overflow-y: auto; align-content: flex-start; justify-content: center; }
        .shape-item { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 4px; cursor: pointer; transition: all 0.15s; color: var(--text-secondary); flex-shrink: 0; }
        .icon-item { }
        .icon-item svg { width: 28px; height: 28px; }
        .resize-handle-right { position: absolute; top: 0; right: 0; width: 5px; height: 100%; cursor: ew-resize; background: transparent; z-index: 10; }
        .resize-handle-right:hover { background: var(--accent-primary); opacity: 0.5; }
        .resize-handle-top { position: absolute; top: 0; left: 0; right: 0; height: 5px; cursor: ns-resize; background: transparent; z-index: 10; }
        .resize-handle-top:hover { background: var(--accent-primary); opacity: 0.5; }
        .shapes-divider-handle { width: 100%; height: 8px; background: var(--border-color); cursor: ns-resize; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
        .shapes-divider-handle:hover { background: var(--accent-primary); }
        .shapes-divider-handle::after { content: ''; width: 30px; height: 3px; background: var(--text-muted); border-radius: 2px; }
        .shape-item:hover { background: var(--bg-elevated); border-color: var(--accent-primary); color: var(--accent-primary); transform: scale(1.05); }
        .shape-item svg { width: 28px; height: 28px; }
        .graph-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
        .graph-container { flex: 1; background: var(--canvas-bg); background-image: linear-gradient(var(--canvas-grid) 1px, transparent 1px), linear-gradient(90deg, var(--canvas-grid) 1px, transparent 1px); background-size: 20px 20px; overflow: hidden; position: relative; }
        .graph-container:focus { outline: 2px solid var(--border-focus); outline-offset: -2px; }
        .text-panel { background: var(--bg-secondary); border-top: 1px solid var(--border-color); display: flex; flex-direction: column; height: 112px; min-height: 36px; max-height: 400px; transition: height 0.2s ease; position: relative; }
        .text-panel.collapsed { height: 36px; min-height: 36px; }
        .text-panel-header { display: flex; align-items: center; padding: 4px 16px; gap: 8px; border-bottom: 1px solid var(--border-color); }
        .text-panel-header h3 { font-size: 12px; font-weight: 500; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; }
        .text-panel-header > h3 > svg { width: 14px; height: 14px; transition: transform 0.2s; }
        .text-panel.collapsed .text-panel-header > h3 > svg { transform: rotate(180deg); }
        .notes-toolbar { display: flex; align-items: center; gap: 4px; margin-left: 12px; flex-wrap: nowrap; overflow: hidden; }
        .notes-toolbar.disabled { opacity: 0.4; pointer-events: none; }
        .notes-toolbar .notes-tb-btn { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; background: none; border: 1px solid transparent; border-radius: 3px; cursor: pointer; color: var(--text-secondary); padding: 0; }
        .notes-toolbar .notes-tb-btn:hover { background: var(--bg-tertiary); border-color: var(--border-color); }
        .notes-toolbar .notes-tb-btn[aria-pressed="true"] { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }
        .notes-toolbar .notes-tb-sep { width: 1px; height: 16px; background: var(--border-color); margin: 0 2px; flex-shrink: 0; }
        .notes-toolbar .notes-tb-select { height: 22px; padding: 0 4px; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 3px; color: var(--text-primary); font-size: 11px; font-family: inherit; cursor: pointer; }
        .notes-toolbar .notes-tb-select:focus { outline: none; border-color: var(--border-focus); }
        .notes-toolbar .notes-color-label { position: relative; display: flex; }
        .notes-toolbar .notes-color-swatch { width: 18px; height: 18px; border-radius: 3px; border: 1px solid var(--border-color); cursor: pointer; }
        .notes-toolbar .notes-color-input { position: absolute; opacity: 0; width: 18px; height: 18px; cursor: pointer; }
        .text-panel.collapsed .notes-toolbar { display: none; }
        .text-panel-content { display: flex; flex: 1; overflow: hidden; }
        .text-panel.collapsed .text-panel-content { display: none; }
        .text-editor-container { flex: 1; display: flex; flex-direction: column; }
        .text-editor { flex: 1; width: 100%; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; color: var(--text-primary); font-family: inherit; font-size: 13px; line-height: 1.5; resize: none; overflow-y: auto; min-height: 60px; white-space: pre-wrap; word-wrap: break-word; }
        .text-editor:focus { outline: none; border-color: var(--border-focus); }
        .text-editor:empty:before { content: attr(data-placeholder); color: var(--text-muted); pointer-events: none; }
        .text-editor[contenteditable="false"] { opacity: 0.6; cursor: not-allowed; }
        .datetime-panel { padding: 12px 16px; border-top: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 8px; }
        .datetime-display { font-size: 12px; color: var(--text-secondary); padding: 8px 12px; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 6px; line-height: 1.5; cursor: pointer; transition: all 0.15s; }
        .datetime-display:hover { background: var(--bg-elevated); border-color: var(--accent-primary); }
        .datetime-display .date-label { color: var(--accent-primary); font-weight: 500; }
        .datetime-display .date-comment { color: var(--text-muted); font-style: italic; margin-top: 4px; }
        .datetime-field { display: flex; flex-direction: column; gap: 4px; }
        .datetime-field label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
        .datetime-field input { height: 36px; padding: 0 10px; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); font-family: inherit; font-size: 13px; }
        .datetime-field input:focus { outline: none; border-color: var(--border-focus); }
        .set-date-btn { padding: 8px 12px; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-secondary); font-size: 12px; cursor: pointer; transition: all 0.15s; }
        .set-date-btn:hover:not(:disabled) { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--accent-primary); }
        .set-date-btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .statusbar { background: var(--bg-secondary); border-top: 1px solid var(--border-color); height: 32px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-size: 12px; color: var(--text-muted); }
        .statusbar-left, .statusbar-right { display: flex; align-items: center; gap: 16px; }
        .statusbar-right { gap: 12px; }
        .zoom-controls { display: flex; align-items: center; gap: 8px; }
        .zoom-btn { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; background: transparent; border: none; border-radius: 4px; cursor: pointer; color: var(--text-secondary); transition: all 0.15s; }
        .zoom-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
        .zoom-btn svg { width: 14px; height: 14px; }
        .zoom-slider { width: 100px; height: 4px; -webkit-appearance: none; background: var(--bg-tertiary); border-radius: 2px; cursor: pointer; }
        .zoom-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; background: var(--accent-primary); border-radius: 50%; cursor: pointer; }
        .zoom-value { font-family: 'JetBrains Mono', monospace; font-size: 11px; min-width: 40px; text-align: center; }
        .toggle-btn { padding: 4px 10px; background: transparent; border: 1px solid var(--border-color); border-radius: 4px; cursor: pointer; color: var(--text-secondary); font-size: 11px; font-family: inherit; transition: all 0.15s; }
        .toggle-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
        .toggle-btn.active { background: var(--accent-tertiary); border-color: var(--accent-secondary); color: var(--text-primary); }
        .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 2000; opacity: 0; visibility: hidden; transition: all 0.2s; }
        .modal-overlay.active { opacity: 1; visibility: visible; }
        .modal { background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 12px; width: 90%; max-width: 500px; max-height: 80vh; overflow: hidden; transform: scale(0.95); transition: transform 0.2s; }
        .modal-overlay.active .modal { transform: scale(1); }
        .modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
        .modal-header h2 { font-size: 16px; font-weight: 600; }
        .modal-close { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: transparent; border: none; border-radius: 6px; cursor: pointer; color: var(--text-secondary); transition: all 0.15s; }
        .modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
        .modal-body { padding: 20px; overflow-y: auto; }
        .modal-footer { padding: 16px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; }
        .btn { padding: 10px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; transition: all 0.15s; }
        .btn-secondary { background: var(--bg-tertiary); border: 1px solid var(--border-color); color: var(--text-primary); }
        .btn-primary { background: var(--accent-tertiary); border: 1px solid var(--accent-secondary); color: var(--text-primary); }
        .btn-primary:hover { background: var(--accent-secondary); }
        .context-menu { position: fixed; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 8px; min-width: 180px; padding: 6px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); z-index: 3000; display: none; }
        .context-menu.active { display: block; animation: dropdownIn 0.15s; }
        .toast-container { position: fixed; bottom: 60px; right: 20px; display: flex; flex-direction: column-reverse; gap: 8px; z-index: 4000; }
        .toast { padding: 12px 20px; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 8px; font-size: 13px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); animation: toastIn 0.3s; }
        .toast.warning { border-left: 3px solid var(--warning); }
        @keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
        .toast.success { border-left: 3px solid var(--success); }
        .toast.error { border-left: 3px solid var(--danger); }
        .recent-map-item { transition: background 0.15s; }
        .recent-map-item:hover { background: var(--bg-tertiary); }
        .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
        :focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: var(--bg-secondary); }
        ::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 4px; }
        .loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-primary); display: flex; align-items: center; justify-content: center; z-index: 9999; flex-direction: column; gap: 16px; }
        .loading-spinner { width: 40px; height: 40px; border: 3px solid var(--border-color); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin 1s linear infinite; }
        @keyframes spin { to { transform: rotate(360deg); } }
        .loading-text { color: var(--text-secondary); font-size: 14px; }

        .map-card { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 10px; overflow: hidden; transition: all 0.2s; cursor: pointer; }
        .map-card:hover { border-color: var(--accent-primary); box-shadow: 0 4px 12px rgba(0,0,0,0.15); transform: translateY(-2px); }
        .map-card.current { border-color: var(--accent-primary); background: var(--accent-primary-alpha, rgba(59, 130, 246, 0.1)); }
        .map-card-preview { height: 120px; background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--border-color); cursor: pointer; }
        .map-card-preview svg { max-width: 100%; max-height: 100%; }
        .map-card-preview .no-preview { color: var(--text-muted); font-size: 12px; }
        .map-card-info { padding: 12px; }
        .map-card-name { font-weight: 600; font-size: 14px; color: var(--text-primary); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .map-card-date { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
        .map-card-current { font-size: 10px; color: var(--accent-primary); font-weight: 500; }
        .map-card-actions { display: flex; gap: 6px; }
        .map-card-actions button { flex: 1; padding: 6px 8px; font-size: 11px; border-radius: 4px; cursor: pointer; border: 1px solid var(--border-color); background: var(--bg-primary); color: var(--text-secondary); transition: all 0.15s; }
        .map-card-actions button:hover { background: var(--bg-tertiary); color: var(--text-primary); }
        .map-card-actions button.delete-btn { color: var(--danger); }
        .map-card-actions button.delete-btn:hover { background: var(--danger); color: white; border-color: var(--danger); }


/* Presentation Mode (app.js enterPresentationMode) */
body.presentation-mode .menubar,
body.presentation-mode .ribbon-wrapper,
body.presentation-mode .sidebar,
body.presentation-mode .shapes-panel,
body.presentation-mode #textPanel {
    display: none !important;
}
body.presentation-mode .graph-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
}
body.presentation-mode #graph-container {
    width: 100%;
    height: 100%;
}
.presentation-bar {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    width: min(820px, calc(100vw - 32px));
    display: flex; align-items: center; gap: 16px; padding: 14px 18px;
    background: var(--bg-elevated); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); z-index: 10001;
}
.presentation-count { font-size: 13px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.presentation-text { flex: 1; min-width: 0; }
.presentation-title { font-size: 18px; font-weight: 600; }
.presentation-notes { font-size: 14px; color: var(--text-secondary); margin-top: 4px; max-height: 6.5em; overflow-y: auto; white-space: pre-wrap; }
.presentation-notes:empty { display: none; }
.presentation-help { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.presentation-exit { border: none; background: transparent; color: var(--text-muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.presentation-exit:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* Notes on a dark background: near-black text colours picked in the notes (the notes
   colour picker defaults to #212529) are shown in the light text colour instead.
   Display only: the saved note HTML keeps the chosen colour. */
.notes-on-dark font[color="#000000" i], .notes-on-dark font[color="#000" i], .notes-on-dark font[color="#212529" i],
.notes-on-dark font[color="#1a1a2e" i], .notes-on-dark font[color="#333333" i], .notes-on-dark font[color="black" i],
.notes-on-dark [style*="color: rgb(0, 0, 0)"], .notes-on-dark [style*="color: rgb(33, 37, 41)"],
.notes-on-dark [style*="color: rgb(26, 26, 46)"], .notes-on-dark [style*="color: rgb(51, 51, 51)"],
.notes-on-dark [style*="color: black"], .notes-on-dark [style*="color:#000"], .notes-on-dark [style*="color: #000"],
.notes-on-dark [style*="color:#212529"], .notes-on-dark [style*="color: #212529"] { color: #f0f0f0 !important; }
/* Highlighted text keeps dark lettering so it stays readable on the (light) highlight */
.notes-on-dark [style*="background-color"]:not([style*="background-color: transparent"]),
.notes-on-dark [style*="background-color"]:not([style*="background-color: transparent"]) * { color: #1a1a2e !important; }

/* Editable equations in notes (MathLive) */
.math-embed { display: inline-block; vertical-align: middle; margin: 0 2px; }
.math-embed[data-display="true"] { display: block; text-align: center; margin: 6px 0; }
.math-embed math-field { display: inline-block; min-width: 2em; padding: 1px 4px; border-radius: 4px; background: transparent; color: inherit; border: 1px dashed transparent; font-size: 1.1em; }
.math-embed math-field:hover { border-color: var(--border-color); }
.math-embed math-field:focus-within { border-color: var(--accent-primary); outline: none; }
.math-embed math-field::part(virtual-keyboard-toggle),
.math-embed math-field::part(menu-toggle) { display: none; }

/* Label editor with equations */
.label-math-editor { min-height: 44px; font-size: 15px; white-space: normal; }
.label-math-editor .math-embed[data-display="true"] { display: inline-block; margin: 0 2px; }
