/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', 'Meiryo', sans-serif;
    font-size: 14px;
    color: #333;
    background: #f5f5f5;
}

/* === Dark Theme === */
[data-theme="dark"] body,
[data-theme="dark"] {
    color: #e0e0e0;
    background: #1e1e1e;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) body,
    html:not([data-theme="light"]) {
        color: #e0e0e0;
        background: #1e1e1e;
        color-scheme: dark;
    }
    html:not([data-theme="light"]) .app-header { background: #0d1b5e; }
    html:not([data-theme="light"]) .auth-page { background: linear-gradient(135deg, #0d1b5e 0%, #1a237e 100%); }
    html:not([data-theme="light"]) .auth-card { background: #2d2d2d; color: #e0e0e0; }
    html:not([data-theme="light"]) .auth-card h1 { color: #7986cb; }
    html:not([data-theme="light"]) .auth-subtitle { color: #aaa; }
    html:not([data-theme="light"]) .auth-link { color: #aaa; }
    html:not([data-theme="light"]) .auth-link a { color: #9fa8da; }
    html:not([data-theme="light"]) .toolbar { background: #2a2d3e; border-color: #3a3d4e; }
    html:not([data-theme="light"]) .toolbar-group { border-color: #3a3d4e; }
    html:not([data-theme="light"]) .btn-toolbar { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .btn-toolbar:hover { background: #4d4d4d; }
    html:not([data-theme="light"]) .btn-toolbar.btn-primary { background: #3949ab; color: white; border-color: #3949ab; }
    html:not([data-theme="light"]) .modal { background: #2d2d2d; color: #e0e0e0; }
    html:not([data-theme="light"]) .document-card { background: #2d2d2d; border-color: #444; }
    html:not([data-theme="light"]) .document-card-meta { color: #aaa; }
    html:not([data-theme="light"]) .doc-dropdown-menu { background: #2d2d2d; border-color: #555; }
    html:not([data-theme="light"]) .doc-dropdown-menu button { color: #e0e0e0; }
    html:not([data-theme="light"]) .doc-dropdown-menu button:hover { background: #3d3d3d; }
    html:not([data-theme="light"]) .doc-dropdown-menu .doc-menu-danger { color: #ef5350; }
    html:not([data-theme="light"]) .document-list-about a { color: #aaa; }
    html:not([data-theme="light"]) .document-rename input { background: #3d3d3d; color: #e0e0e0; border-color: #3949ab; }
    html:not([data-theme="light"]) .search-input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .search-input:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
    html:not([data-theme="light"]) .empty-state,
    html:not([data-theme="light"]) .loading { color: #aaa; }
    html:not([data-theme="light"]) .editor-left { background: #252525; border-color: #444; }
    html:not([data-theme="light"]) .editor-main { background: #1e1e1e; }
    html:not([data-theme="light"]) .editor-resizer { background: #444; }
    html:not([data-theme="light"]) .editor-resizer:hover { background: #5c6bc0; }
    html:not([data-theme="light"]) .function-editor { background: #2d2d2d; border-color: #444; }
    html:not([data-theme="light"]) .function-editor.empty { color: #aaa; }
    html:not([data-theme="light"]) .logic-editor { background: #2d2d2d; border-color: #444; }
    html:not([data-theme="light"]) .rich-text-editor { background: #2d2d2d; border-color: #444; }
    html:not([data-theme="light"]) .rich-text-editor .ql-toolbar { border-color: #444; }
    html:not([data-theme="light"]) .rich-text-editor .ql-toolbar button { color: #ccc; }
    html:not([data-theme="light"]) .rich-text-editor .ql-container { color: #e0e0e0; }
    html:not([data-theme="light"]) .rich-text-editor .ql-editor.ql-blank::before { color: #888; }
    html:not([data-theme="light"]) .tree-header,
    html:not([data-theme="light"]) .logic-header { background: #333; border-color: #444; }
    html:not([data-theme="light"]) .tree-node:hover { background: #3a3d4e; }
    html:not([data-theme="light"]) .tree-node.selected { background: #2a3a5e; }
    html:not([data-theme="light"]) .tree-toc-number { color: #aaa; }
    html:not([data-theme="light"]) .tree-type-badge { background: #2a3a5e; color: #9fa8da; }
    html:not([data-theme="light"]) .tree-empty { color: #aaa; }
    html:not([data-theme="light"]) .btn { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .btn:hover { background: #4d4d4d; }
    html:not([data-theme="light"]) .btn-primary { background: #3949ab; color: white; border-color: #3949ab; }
    html:not([data-theme="light"]) .btn-primary:hover { background: #5c6bc0; border-color: #5c6bc0; }
    html:not([data-theme="light"]) .btn-danger { background: #c62828; color: white; border-color: #c62828; }
    html:not([data-theme="light"]) .btn-danger:hover { background: #e53935; border-color: #e53935; }
    html:not([data-theme="light"]) .btn-icon:hover { background: rgba(255,255,255,0.1); }
    html:not([data-theme="light"]) .form-group label { color: #bbb; }
    html:not([data-theme="light"]) .form-group input,
    html:not([data-theme="light"]) .form-group select,
    html:not([data-theme="light"]) .form-group textarea { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .form-group input:focus,
    html:not([data-theme="light"]) .form-group select:focus,
    html:not([data-theme="light"]) .form-group textarea:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
    html:not([data-theme="light"]) .fe-field label { color: #bbb; }
    html:not([data-theme="light"]) .fe-field input,
    html:not([data-theme="light"]) .fe-field select,
    html:not([data-theme="light"]) .fe-field textarea { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .fe-field input:focus,
    html:not([data-theme="light"]) .fe-field select:focus,
    html:not([data-theme="light"]) .fe-field textarea:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
    html:not([data-theme="light"]) .readonly { background: #333; color: #999; }
    html:not([data-theme="light"]) .error-message { background: #4a1c1c; color: #ef9a9a; }
    html:not([data-theme="light"]) .info-message { background: #1a2a4a; color: #90caf9; }
    html:not([data-theme="light"]) .field-hint { color: #aaa; }
    html:not([data-theme="light"]) .field-error { color: #ef5350; }
    html:not([data-theme="light"]) .checkbox-label { color: #aaa; }
    html:not([data-theme="light"]) .checkbox-label input[type="checkbox"],
    html:not([data-theme="light"]) .radio-label input[type="radio"] { accent-color: #5c6bc0; }
    html:not([data-theme="light"]) input[type="checkbox"] { accent-color: #5c6bc0; }
    html:not([data-theme="light"]) .radio-label { color: #aaa; }
    html:not([data-theme="light"]) .settings-section { border-color: #444; }
    html:not([data-theme="light"]) .settings-section h4 { color: #e0e0e0; }
    html:not([data-theme="light"]) .settings-description { color: #aaa; }
    html:not([data-theme="light"]) .settings-row label { color: #bbb; }
    html:not([data-theme="light"]) .settings-row input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .settings-row input:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
    html:not([data-theme="light"]) .left-pane-tabs { background: #2a2d3e; border-color: #3a3d4e; }
    html:not([data-theme="light"]) .left-pane-tab { color: #aaa; }
    html:not([data-theme="light"]) .left-pane-tab:hover { background: #3a3d4e; }
    html:not([data-theme="light"]) .left-pane-tab.active { color: #9fa8da; border-bottom-color: #9fa8da; }
    html:not([data-theme="light"]) .right-pane-tabs { background: #2a2d3e; border-color: #3a3d4e; }
    html:not([data-theme="light"]) .right-pane-tab { color: #aaa; }
    html:not([data-theme="light"]) .right-pane-tab:hover { background: #3a3d4e; }
    html:not([data-theme="light"]) .right-pane-tab.active { color: #9fa8da; border-bottom-color: #9fa8da; }
    html:not([data-theme="light"]) .right-pane-empty { color: #aaa; }
    html:not([data-theme="light"]) .function-list-actions { border-color: #444; }
    html:not([data-theme="light"]) .function-list-table th { background: #333; border-color: #444; }
    html:not([data-theme="light"]) .function-list-table th.sortable:hover { background: #3a3d4e; }
    html:not([data-theme="light"]) .function-list-table td { border-color: #3a3a3a; }
    html:not([data-theme="light"]) .function-list-table tr:hover { background: #3a3d4e; }
    html:not([data-theme="light"]) .function-list-table tr.selected { background: #2a3a5e; }
    html:not([data-theme="light"]) .logic-line { border-color: #3a3a3a; background: #2d2d2d; color: #e0e0e0; }
    html:not([data-theme="light"]) .logic-line-selected { outline-color: #7986cb; background: #3a3d4e !important; }
    html:not([data-theme="light"]) .logic-line-number { color: #777777; }
    html:not([data-theme="light"]) .logic-const-label { color: #7986cb; }
    html:not([data-theme="light"]) .logic-bracket { color: #7986cb; }
    html:not([data-theme="light"]) .logic-memo { color: #777777; }
    html:not([data-theme="light"]) .logic-empty { color: #777777; }
    html:not([data-theme="light"]) .logic-mark-input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .logic-mark-input:focus { border-color: #7986cb; box-shadow: 0 0 0 2px rgba(121,134,203,0.3); outline: none; }
    html:not([data-theme="light"]) .logic-select-type { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .logic-input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .logic-select-type:focus,
    html:not([data-theme="light"]) .logic-input:focus { border-color: #7986cb; box-shadow: 0 0 0 2px rgba(121,134,203,0.3); }
    html:not([data-theme="light"]) .add-menu { background: #2d2d2d; border-color: #555; }
    html:not([data-theme="light"]) .add-menu-item { color: #e0e0e0; }
    html:not([data-theme="light"]) .add-menu-item:hover { background: #3a3d4e; }
    html:not([data-theme="light"]) .search-controls { border-color: #444; }
    html:not([data-theme="light"]) .replace-controls { border-color: #444; }
    html:not([data-theme="light"]) .search-tab-input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .search-tab-input:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
    html:not([data-theme="light"]) .search-options { background: #2a2a2a; border-color: #444; }
    html:not([data-theme="light"]) .search-option-label { color: #bbb; }
    html:not([data-theme="light"]) .search-option-group select { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
    html:not([data-theme="light"]) .search-empty { color: #aaa; }
    html:not([data-theme="light"]) .search-results-table th { background: #333; border-color: #444; }
    html:not([data-theme="light"]) .search-results-table td { border-color: #3a3a3a; }
    html:not([data-theme="light"]) .search-result-row:hover { background: #3a3d4e; }
    html:not([data-theme="light"]) .search-result-selected { background: #2a3a5e; }
    html:not([data-theme="light"]) .search-result-selected:hover { background: #334670; }
    html:not([data-theme="light"]) .toc-toolbar { background: #2a2a2a; border-color: #444; }
    html:not([data-theme="light"]) .toc-dropdown-menu { background: #2d2d2d; border-color: #555; }
    html:not([data-theme="light"]) .toc-dropdown-menu button { color: #e0e0e0; }
    html:not([data-theme="light"]) .toc-dropdown-menu button:hover:not(:disabled) { background: #3d3d3d; }
    html:not([data-theme="light"]) .toc-dropdown-menu button:disabled { color: #666; }
    html:not([data-theme="light"]) .note-textarea { background: #2d2d2d; color: #e0e0e0; }
    html:not([data-theme="light"]) .about-card h2 { color: #bbb; }
    html:not([data-theme="light"]) .about-content h3 { color: #e0e0e0; }
    html:not([data-theme="light"]) .about-content a { color: #7986cb; }
}
[data-theme="dark"] .app-header { background: #0d1b5e; }
[data-theme="dark"] .auth-page { background: linear-gradient(135deg, #0d1b5e 0%, #1a237e 100%); }
[data-theme="dark"] .auth-card { background: #2d2d2d; color: #e0e0e0; }
[data-theme="dark"] .auth-card h1 { color: #7986cb; }
[data-theme="dark"] .auth-subtitle { color: #aaa; }
[data-theme="dark"] .auth-link { color: #aaa; }
[data-theme="dark"] .auth-link a { color: #9fa8da; }
[data-theme="dark"] .toolbar { background: #2a2d3e; border-color: #3a3d4e; }
[data-theme="dark"] .toolbar-group { border-color: #3a3d4e; }
[data-theme="dark"] .btn-toolbar { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .btn-toolbar:hover { background: #4d4d4d; }
[data-theme="dark"] .btn-toolbar.btn-primary { background: #3949ab; color: white; border-color: #3949ab; }
[data-theme="dark"] .modal { background: #2d2d2d; color: #e0e0e0; }
[data-theme="dark"] .document-card { background: #2d2d2d; border-color: #444; }
[data-theme="dark"] .document-card-meta { color: #aaa; }
[data-theme="dark"] .doc-dropdown-menu { background: #2d2d2d; border-color: #555; }
[data-theme="dark"] .doc-dropdown-menu button { color: #e0e0e0; }
[data-theme="dark"] .doc-dropdown-menu button:hover { background: #3d3d3d; }
[data-theme="dark"] .doc-dropdown-menu .doc-menu-danger { color: #ef5350; }
[data-theme="dark"] .document-list-about a { color: #aaa; }
[data-theme="dark"] .document-rename input { background: #3d3d3d; color: #e0e0e0; border-color: #3949ab; }
[data-theme="dark"] .search-input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .search-input:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
[data-theme="dark"] .sort-box select { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .empty-state,
[data-theme="dark"] .loading { color: #aaa; }
[data-theme="dark"] .editor-left { background: #252525; border-color: #444; }
[data-theme="dark"] .editor-main { background: #1e1e1e; }
[data-theme="dark"] .editor-resizer { background: #444; }
[data-theme="dark"] .editor-resizer:hover { background: #5c6bc0; }
[data-theme="dark"] .function-editor { background: #2d2d2d; border-color: #444; }
[data-theme="dark"] .function-editor.empty { color: #aaa; }
[data-theme="dark"] .logic-editor { background: #2d2d2d; border-color: #444; }
[data-theme="dark"] .rich-text-editor { background: #2d2d2d; border-color: #444; }
[data-theme="dark"] .rich-text-editor .ql-toolbar { border-color: #444; }
[data-theme="dark"] .rich-text-editor .ql-toolbar button { color: #ccc; }
[data-theme="dark"] .rich-text-editor .ql-container { color: #e0e0e0; }
[data-theme="dark"] .rich-text-editor .ql-editor.ql-blank::before { color: #888; }
[data-theme="dark"] .tree-header,
[data-theme="dark"] .logic-header { background: #333; border-color: #444; }
[data-theme="dark"] .tree-node:hover { background: #3a3d4e; }
[data-theme="dark"] .tree-node.selected { background: #2a3a5e; }
[data-theme="dark"] .tree-toc-number { color: #aaa; }
[data-theme="dark"] .tree-type-badge { background: #2a3a5e; color: #9fa8da; }
[data-theme="dark"] .tree-empty { color: #aaa; }
[data-theme="dark"] .btn { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .btn:hover { background: #4d4d4d; }
[data-theme="dark"] .btn-primary { background: #3949ab; color: white; border-color: #3949ab; }
[data-theme="dark"] .btn-primary:hover { background: #5c6bc0; border-color: #5c6bc0; }
[data-theme="dark"] .btn-danger { background: #c62828; color: white; border-color: #c62828; }
[data-theme="dark"] .btn-danger:hover { background: #e53935; border-color: #e53935; }
[data-theme="dark"] .btn-icon:hover { background: rgba(255,255,255,0.1); }
[data-theme="dark"] .form-group label { color: #bbb; }
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
[data-theme="dark"] .fe-field label { color: #bbb; }
[data-theme="dark"] .fe-field input,
[data-theme="dark"] .fe-field select,
[data-theme="dark"] .fe-field textarea { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .fe-field input:focus,
[data-theme="dark"] .fe-field select:focus,
[data-theme="dark"] .fe-field textarea:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
[data-theme="dark"] .readonly { background: #333; color: #999; }
[data-theme="dark"] .error-message { background: #4a1c1c; color: #ef9a9a; }
[data-theme="dark"] .info-message { background: #1a2a4a; color: #90caf9; }
[data-theme="dark"] .field-hint { color: #aaa; }
[data-theme="dark"] .field-error { color: #ef5350; }
[data-theme="dark"] .checkbox-label { color: #aaa; }
[data-theme="dark"] .checkbox-label input[type="checkbox"],
[data-theme="dark"] .radio-label input[type="radio"] { accent-color: #5c6bc0; }
[data-theme="dark"] input[type="checkbox"] { accent-color: #5c6bc0; }
[data-theme="dark"] .radio-label { color: #aaa; }
[data-theme="dark"] .settings-section { border-color: #444; }
[data-theme="dark"] .settings-section h4 { color: #e0e0e0; }
[data-theme="dark"] .settings-description { color: #aaa; }
[data-theme="dark"] .settings-row label { color: #bbb; }
[data-theme="dark"] .settings-row input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .settings-row input:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
[data-theme="dark"] .left-pane-tabs { background: #2a2d3e; border-color: #3a3d4e; }
[data-theme="dark"] .left-pane-tab { color: #aaa; }
[data-theme="dark"] .left-pane-tab:hover { background: #3a3d4e; }
[data-theme="dark"] .left-pane-tab.active { color: #9fa8da; border-bottom-color: #9fa8da; }
[data-theme="dark"] .right-pane-tabs { background: #2a2d3e; border-color: #3a3d4e; }
[data-theme="dark"] .right-pane-tab { color: #aaa; }
[data-theme="dark"] .right-pane-tab:hover { background: #3a3d4e; }
[data-theme="dark"] .right-pane-tab.active { color: #9fa8da; border-bottom-color: #9fa8da; }
[data-theme="dark"] .right-pane-empty { color: #aaa; }
[data-theme="dark"] .function-list-actions { border-color: #444; }
[data-theme="dark"] .function-list-table th { background: #333; border-color: #444; }
[data-theme="dark"] .function-list-table th.sortable:hover { background: #3a3d4e; }
[data-theme="dark"] .function-list-table td { border-color: #3a3a3a; }
[data-theme="dark"] .function-list-table tr:hover { background: #3a3d4e; }
[data-theme="dark"] .function-list-table tr.selected { background: #2a3a5e; }
[data-theme="dark"] .logic-line { border-color: #3a3a3a; background: #2d2d2d; color: #e0e0e0; }
[data-theme="dark"] .logic-line-selected { outline-color: #7986cb; background: #3a3d4e !important; }
[data-theme="dark"] .logic-line-number { color: #777777; }
[data-theme="dark"] .logic-const-label { color: #7986cb; }
[data-theme="dark"] .logic-bracket { color: #7986cb; }
[data-theme="dark"] .logic-memo { color: #777777; }
[data-theme="dark"] .logic-empty { color: #777777; }
[data-theme="dark"] .logic-mark-input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .logic-mark-input:focus { border-color: #7986cb; box-shadow: 0 0 0 2px rgba(121,134,203,0.3); outline: none; }
[data-theme="dark"] .logic-select-type { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .logic-input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .logic-select-type:focus,
[data-theme="dark"] .logic-input:focus { border-color: #7986cb; box-shadow: 0 0 0 2px rgba(121,134,203,0.3); }
[data-theme="dark"] .add-menu { background: #2d2d2d; border-color: #555; }
[data-theme="dark"] .add-menu-item { color: #e0e0e0; }
[data-theme="dark"] .add-menu-item:hover { background: #3a3d4e; }
[data-theme="dark"] .search-controls { border-color: #444; }
[data-theme="dark"] .replace-controls { border-color: #444; }
[data-theme="dark"] .search-tab-input { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .search-tab-input:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(92,107,192,0.3); }
[data-theme="dark"] .search-options { background: #2a2a2a; border-color: #444; }
[data-theme="dark"] .search-option-label { color: #bbb; }
[data-theme="dark"] .search-option-group select { background: #3d3d3d; color: #e0e0e0; border-color: #555; }
[data-theme="dark"] .search-empty { color: #aaa; }
[data-theme="dark"] .search-results-table th { background: #333; border-color: #444; }
[data-theme="dark"] .search-results-table td { border-color: #3a3a3a; }
[data-theme="dark"] .search-result-row:hover { background: #3a3d4e; }
[data-theme="dark"] .search-result-selected { background: #2a3a5e; }
[data-theme="dark"] .search-result-selected:hover { background: #334670; }
[data-theme="dark"] .toc-toolbar { background: #2a2a2a; border-color: #444; }
[data-theme="dark"] .toc-dropdown-menu { background: #2d2d2d; border-color: #555; }
[data-theme="dark"] .toc-dropdown-menu button { color: #e0e0e0; }
[data-theme="dark"] .toc-dropdown-menu button:hover:not(:disabled) { background: #3d3d3d; }
[data-theme="dark"] .toc-dropdown-menu button:disabled { color: #666; }
[data-theme="dark"] .note-textarea { background: #2d2d2d; color: #e0e0e0; }
[data-theme="dark"] .about-card h2 { color: #bbb; }
[data-theme="dark"] .about-content h3 { color: #e0e0e0; }
[data-theme="dark"] .about-content a { color: #7986cb; }

/* === App Layout === */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* === Header === */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 48px;
    background: #1a237e;
    color: white;
    flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.app-logo {
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    letter-spacing: 2px;
}
.header-doc-title {
    font-size: 14px;
    opacity: 0.9;
}
.header-right { display: flex; align-items: center; gap: 8px; }
.header-username {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
}
.header-username:hover {
    background: rgba(255,255,255,0.15);
}

/* === Buttons === */
.btn {
    padding: 6px 12px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.btn:hover { background: #f0f0f0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #1a237e; color: white; border-color: #1a237e; }
.btn-primary:hover { background: #283593; }
.btn-danger { background: #c62828; color: white; border-color: #c62828; }
.btn-danger:hover { background: #d32f2f; }
.btn-text { background: none; border: none; color: white; cursor: pointer; }
.btn-text:hover { text-decoration: underline; }
.btn-small { padding: 3px 8px; font-size: 12px; }
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 3px;
    color: inherit;
}
.btn-icon:hover { background: rgba(0,0,0,0.1); }

/* === Toolbar === */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #e8eaf6;
    border-bottom: 1px solid #c5cae9;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.toolbar-group {
    display: flex;
    gap: 4px;
    padding-right: 8px;
    border-right: 1px solid #c5cae9;
    align-items: center;
}
.toolbar-group:last-child { border-right: none; }
.toolbar-doc-title { font-weight: 600; font-size: 13px; }
.toolbar-title-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.btn-toolbar {
    padding: 4px 10px;
    border: 1px solid #9fa8da;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}
.btn-toolbar:hover { background: #c5cae9; }
.btn-toolbar.btn-primary { background: #3949ab; color: white; border-color: #3949ab; }

/* === Auth Pages === */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
}
.auth-card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    width: 400px;
    max-width: 90vw;
}
.auth-card h1 {
    text-align: center;
    color: #1a237e;
    font-size: 32px;
    letter-spacing: 4px;
    margin-bottom: 4px;
}
.auth-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 24px;
}
.auth-link {
    text-align: center;
    margin-top: 16px;
    color: #666;
    font-size: 13px;
}
.auth-link a { color: #1a237e; }
.about-page {
    overflow-y: auto;
}
.about-back-fixed {
    z-index: 10;
}
.about-back-fixed .btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    background: #e65100;
    color: white;
    border-color: #e65100;
}
.about-back-fixed .btn:hover {
    background: #f57c00;
    border-color: #f57c00;
}
.about-card {
    width: 1000px;
    margin: 40px 0;
}
.about-card h2 {
    text-align: center;
    color: #555;
    font-size: 16px;
    margin-bottom: 20px;
}
.about-content {
    margin-bottom: 24px;
    line-height: 1.8;
}
.about-content h3 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #333;
}
.about-content ul {
    padding-left: 24px;
}
.about-content li {
    margin-bottom: 4px;
}
.about-content p {
    margin-bottom: 8px;
}
/* === Password field === */
.password-field {
    position: relative;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    cursor: pointer;
}
.radio-label input[type="radio"] {
    width: auto;
}
.field-hint {
    display: block;
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}
.field-error {
    display: block;
    font-size: 12px;
    color: #c62828;
    margin-top: 2px;
}

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 13px;
    color: #555;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3949ab;
    box-shadow: 0 0 0 2px rgba(57,73,171,0.2);
}
.error-message {
    color: #c62828;
    font-size: 13px;
    margin-bottom: 12px;
    padding: 8px;
    background: #ffebee;
    border-radius: 4px;
}
.info-message {
    color: #1565c0;
    font-size: 13px;
    margin-bottom: 12px;
    padding: 8px;
    background: #e3f2fd;
    border-radius: 4px;
}
.auth-card .btn-primary {
    width: 100%;
    padding: 10px;
    font-size: 15px;
}

/* === Settings === */
.settings-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}
.settings-section:last-child {
    border-bottom: none;
}
.settings-section h4 {
    margin-bottom: 12px;
    font-size: 14px;
    color: #333;
}
.settings-description {
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
}
.settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.settings-row label {
    min-width: 120px;
    font-size: 13px;
    color: #555;
}
.settings-row input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
}
.settings-row input:focus {
    outline: none;
    border-color: #3949ab;
    box-shadow: 0 0 0 2px rgba(57,73,171,0.2);
}

/* === Document List === */
.document-list-page {
    padding: 24px;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}
.document-list-about {
    text-align: center;
    margin-bottom: 16px;
}
.document-list-about a {
    color: #666;
    font-size: 13px;
}
.document-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.document-list-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.search-box { }
.sort-box {
    display: flex;
    gap: 4px;
    align-items: stretch;
}
.sort-box select {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    box-sizing: border-box;
    height: 100%;
}
.search-input {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    width: 200px;
}
.search-input:focus {
    outline: none;
    border-color: #3949ab;
    box-shadow: 0 0 0 2px rgba(57,73,171,0.2);
}
.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.document-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    position: relative;
    cursor: pointer;
    transition: box-shadow 0.2s;
    position: relative;
}
.document-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.document-card-menu-open {
    z-index: 20;
}
.document-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}
.document-card-meta {
    font-size: 12px;
    color: #888;
    display: flex;
    gap: 12px;
}
.document-card-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 10;
}
.doc-menu-wrapper { position: relative; display: inline-block; }
.doc-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 140px;
}
.doc-dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}
.doc-dropdown-menu button:hover { background: #f0f0f0; }
.doc-dropdown-menu-up { top: auto; bottom: 100%; }
.doc-dropdown-menu-right { left: auto; right: 0; }
.doc-menu-danger { color: #c62828; }
.document-rename {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 8px;
}
.document-rename input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #3949ab;
    border-radius: 3px;
    font-size: 14px;
}
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}
.loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: white;
    border-radius: 8px;
    padding: 24px;
    width: 450px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-large {
    width: 700px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* === Editor Layout === */
.editor-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}
.editor-left {
    min-width: 200px;
    border-right: 1px solid #e0e0e0;
    overflow: hidden;
    background: white;
    display: flex;
    flex-direction: column;
}
.editor-resizer {
    width: 4px;
    cursor: col-resize;
    background: #e0e0e0;
    flex-shrink: 0;
}
.editor-resizer:hover {
    background: #3949ab;
}
.editor-main {
    flex: 1;
    overflow-y: auto;
    background: #fafafa;
}
.right-pane-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #888;
    font-size: 14px;
}

/* === Left Pane Tabs === */
.left-pane {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.left-pane-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    background: #f5f5f5;
    flex-shrink: 0;
}
.left-pane-tab {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-bottom: 2px solid transparent;
    text-align: center;
    white-space: nowrap;
}
.left-pane-tab:hover { background: #e8eaf6; }
.left-pane-tab.active {
    color: #1a237e;
    font-weight: 600;
    border-bottom-color: #1a237e;
}
.left-pane-content {
    flex: 1;
    overflow-y: auto;
}

/* === Right Pane Tabs === */
.right-pane {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.right-pane-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    background: #f5f5f5;
    flex-shrink: 0;
    padding: 0 12px;
}
.right-pane-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-bottom: 2px solid transparent;
}
.right-pane-tab:hover { background: #e8eaf6; }
.right-pane-tab.active {
    color: #1a237e;
    font-weight: 600;
    border-bottom-color: #1a237e;
}
.right-pane-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}
.right-pane-content-fill {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === Function List Table === */
.function-list-tab {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.function-list-actions {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    border-bottom: 1px solid #e0e0e0;
}
.function-list-table {
    flex: 1;
    overflow-y: auto;
}
.function-list-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.function-list-table th {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    padding: 4px 6px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
    font-size: 11px;
    white-space: nowrap;
}
.function-list-table th.sortable {
    cursor: pointer;
}
.function-list-table th.sortable:hover {
    background: #e8eaf6;
}
.function-list-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.function-list-table tr {
    cursor: pointer;
}
.function-list-table tr:hover {
    background: #e8eaf6;
}
.function-list-table tr.selected {
    background: #c5cae9;
    font-weight: 600;
}
.func-name-cell {
    max-width: 160px;
}

/* === Tree View === */
.tree-view { height: 100%; display: flex; flex-direction: column; }
.tree-header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid #e0e0e0;
    background: #f5f5f5;
}
.tree-content { flex: 1; overflow-y: auto; padding: 4px 0; }
.tree-node {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}
.tree-node:hover { background: #e8eaf6; }
.tree-node.selected { background: #c5cae9; font-weight: 600; }
.tree-toggle {
    display: inline-block;
    width: 16px;
    font-size: 10px;
    cursor: pointer;
    text-align: center;
    flex-shrink: 0;
}
.tree-toggle-placeholder { display: inline-block; width: 16px; flex-shrink: 0; }
.tree-node-name { overflow: hidden; text-overflow: ellipsis; }
.tree-toc-number {
    margin-right: 6px;
    color: #666;
    font-size: 12px;
}
.tree-type-badge {
    display: inline-block;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    background: #e8eaf6;
    color: #3949ab;
    margin-right: 4px;
    font-weight: 600;
}
.tree-empty { padding: 20px; text-align: center; color: #888; font-size: 13px; }

/* === TOC Toolbar === */
.toc-tab-container { display: flex; flex-direction: column; height: 100%; }
.toc-tab-container .tree-view { flex: 1; overflow: auto; }
.toc-toolbar { padding: 4px 8px; border-bottom: 1px solid #e0e0e0; background: #fafafa; }
.toc-menu-wrapper { position: relative; display: inline-block; }
.toc-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 160px;
}
.toc-dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}
.toc-dropdown-menu button:hover:not(:disabled) { background: #f0f0f0; }
.toc-dropdown-menu button:disabled { color: #aaa; cursor: default; }

/* === Function Editor === */
.function-editor {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}
.function-editor.empty {
    text-align: center;
    color: #888;
    padding: 40px;
}
.fe-row {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}
.fe-field { flex: 1; margin-top: 12px; }
.fe-field:first-child { margin-top: 0; }
.fe-field label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
    font-weight: 500;
}
.fe-field input,
.fe-field select,
.fe-field textarea {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
}
.fe-field input:focus,
.fe-field select:focus,
.fe-field textarea:focus {
    outline: none;
    border-color: #3949ab;
}
.fe-field-small { flex: 0 0 120px; }
.fe-field-tiny { flex: 0 0 80px; display: flex; align-items: flex-end; }
.fe-field-tiny label { display: flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.fe-inline { display: flex; gap: 4px; }
.fe-inline input { flex: 1; }
.fe-inline select { flex: 0 0 50px; }
.fe-name-row { display: flex; gap: 4px; align-items: center; }
.fe-name-row input { flex: 1; }
.readonly { background: #f5f5f5; color: #888; }

/* === Rich Text Editor === */
.rich-text-editor {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.rich-text-editor .ql-toolbar { border: none; border-bottom: 1px solid #e0e0e0; flex-shrink: 0; }
.rich-text-editor .ql-container { border: none; flex: 1; overflow-y: auto; font-size: 14px; }
#editor-resizer .toolbar { top: 0 !important; left: 0 !important; transform: none !important; display: flex !important; flex-direction: column !important; }
#editor-resizer .toolbar .group { width: 100% !important; box-sizing: border-box !important; border: none !important; }
#editor-resizer .toolbar .group .btn:not(:last-child) { border-right: none !important; }
#editor-resizer .toolbar .group .input-wrapper { min-width: 0 !important; }

/* === Logic Editor === */
.logic-editor {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.logic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid #e0e0e0;
    background: #f5f5f5;
}
.logic-header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.logic-lines { flex: 1; overflow: auto; }
.logic-empty {
    padding: 20px;
    text-align: center;
    color: #999999;
    font-size: 13px;
}
.logic-line {
    display: flex;
    align-items: center;
    padding: 3px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    min-height: 30px;
    background: #ffffff;
    color: #333333;
    white-space: nowrap;
    width: fit-content;
    min-width: 100%;
}
.logic-line:hover { filter: brightness(0.97); }
.logic-line-selected { outline: 2px solid #5c6bc0; outline-offset: -2px; background: #e8eaf6 !important; }
.logic-line-indent { flex-shrink: 0; }
.logic-line-leading {
    flex-shrink: 0;
    display: flex;
    gap: 2px;
    align-items: center;
}
.logic-line-mark {
    flex-shrink: 0;
    cursor: pointer;
    align-self: stretch;
    display: flex;
    align-items: center;
}
.logic-mark-text {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
.logic-mark-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: white;
    font-size: 12px;
    padding: 3px 6px;
}
.logic-mark-input:focus {
    outline: none;
    border-color: #5c6bc0;
    box-shadow: 0 0 0 2px rgba(92,107,192,0.2);
}
.logic-line-number {
    width: 28px;
    text-align: right;
    font-size: 11px;
    color: #999999;
    margin-right: 4px;
    flex-shrink: 0;
}
.logic-line-content {
    flex: 1;
    display: flex;
    align-items: center;
    align-self: stretch;
    gap: 4px;
    cursor: pointer;
    min-height: 24px;
}
.logic-const-label {
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
    color: #5c6bc0;
}
.logic-text { white-space: nowrap; }
.logic-bracket { color: #5c6bc0; }
.logic-field-member { font-weight: 500; }
.logic-field-state { font-weight: 500; }
.logic-fn-text { font-weight: 500; }
.logic-memo { font-size: 11px; color: #999999; margin-left: 8px; flex-shrink: 0; }
.logic-fn-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    align-items: center;
}
.logic-line-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    align-items: center;
}
.logic-line:hover .logic-line-actions { opacity: 1; }

/* Add menu */
.add-menu-container {
    position: relative;
    display: inline-block;
}
.add-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
}
.add-menu {
    position: fixed;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 120px;
    max-height: 50vh;
    overflow-y: auto;
}
.add-menu-item {
    display: block;
    width: 100%;
    padding: 6px 12px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 12px;
    color: #333;
}
.add-menu-item:hover {
    background: #e8eaf6;
}

/* Logic line editor */
.logic-line-edit {
    display: flex;
    gap: 4px;
    flex: 1;
    align-items: center;
    flex-wrap: wrap;
    margin-left: 8px;
}
.logic-select-type {
    width: 70px;
    padding: 3px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
}
.logic-input {
    flex: 1;
    padding: 3px 6px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    min-width: 60px;
}
.logic-select-type:focus,
.logic-input:focus {
    outline: none;
    border-color: #5c6bc0;
    box-shadow: 0 0 0 2px rgba(92,107,192,0.2);
}
.logic-input-small { max-width: 80px; flex: 0 0 80px; }
.logic-input-wide { min-width: 200px; }
.logic-input-memo { max-width: 120px; }

/* === Search Tab === */
.search-tab {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.search-controls {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid #e0e0e0;
}
.search-tab-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
}
.search-tab-input:focus {
    outline: none;
    border-color: #3949ab;
    box-shadow: 0 0 0 2px rgba(57,73,171,0.2);
}
.search-options {
    padding: 8px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}
.search-option-group {
    margin-bottom: 8px;
}
.search-option-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}
.search-option-group select {
    width: 100%;
    padding: 3px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
}
.search-results {
    flex: 1;
    overflow-y: auto;
}
.replace-controls {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-top: 1px solid #e0e0e0;
}
.search-empty {
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 12px;
}
.search-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.search-results-table th {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    padding: 4px 6px;
    text-align: left;
    font-size: 11px;
    border-bottom: 1px solid #e0e0e0;
}
.search-results-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #f0f0f0;
}
.search-result-row {
    cursor: pointer;
}
.search-result-row:hover {
    background: #e8eaf6;
}
.search-result-selected {
    background: #c5cae9;
}
.search-result-selected:hover {
    background: #b0bec5;
}

/* === Note Tab === */
.note-tab {
    height: 100%;
    display: flex;
}
.note-textarea {
    width: 100%;
    height: 100%;
    border: none;
    padding: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
}

/* === App Dialog (custom alert/confirm/prompt) === */
.app-dialog {
    border: none;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    width: 400px;
    max-width: 90vw;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}
.app-dialog::backdrop {
    background: rgba(0,0,0,0.5);
}
.app-dialog-body {
    padding: 24px;
}
.app-dialog-message {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}
.app-dialog-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 16px;
}
.app-dialog-input:focus {
    outline: none;
    border-color: #3949ab;
    box-shadow: 0 0 0 2px rgba(57,73,171,0.2);
}
.app-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.func-picker-list {
    margin: 8px 0;
}
.func-picker-select {
    width: 100%;
    min-width: 300px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px;
}

/* Dark theme for app-dialog */
[data-theme="dark"] .app-dialog {
    background: #2d2d2d;
    color: #e0e0e0;
}
[data-theme="dark"] .app-dialog-input,
[data-theme="dark"] .func-picker-select {
    background: #3d3d3d;
    color: #e0e0e0;
    border-color: #555;
}
[data-theme="dark"] .app-dialog-input:focus,
[data-theme="dark"] .func-picker-select:focus {
    border-color: #5c6bc0;
    box-shadow: 0 0 0 2px rgba(92,107,192,0.3);
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .app-dialog {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    html:not([data-theme="light"]) .app-dialog-input,
    html:not([data-theme="light"]) .func-picker-select {
        background: #3d3d3d;
        color: #e0e0e0;
        border-color: #555;
    }
    html:not([data-theme="light"]) .app-dialog-input:focus,
    html:not([data-theme="light"]) .func-picker-select:focus {
        border-color: #5c6bc0;
        box-shadow: 0 0 0 2px rgba(92,107,192,0.3);
    }
}


