
.clause-library-wrapper * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        .clause-library-wrapper {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            background: #f5f5f5;
            padding: 20px;
            padding-bottom: 40px;
            margin: 0;
            min-height: 100vh;
        }
        
        .clause-library-wrapper .container {
            max-width: 1600px;
            margin: 0 auto;
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            display: flex;
            flex-direction: column;
            min-height: calc(100vh - 40px);
        }
        
        .clause-library-wrapper .footer {
            margin-top: 20px;
            text-align: center;
            color: #7f8c8d;
            font-size: 12px;
            padding: 10px;
        }
        
        .clause-library-wrapper .header {
            background: #1A56A3;
            color: white;
            padding: 20px;
        }
        
        .clause-library-wrapper .header h1 {
            font-size: 24px;
            font-weight: 600;
            color: white !important;
        }
        
        .clause-library-wrapper .tabs {
            display: flex;
            background: #2667C1;
            border-bottom: 2px solid #1A56A3;
        }
        
        .clause-library-wrapper .tab {
            padding: 15px 30px;
            background: #E8F0F8;
            color: #1A56A3;
            cursor: pointer;
            border: none;
            border-radius: 0 !important;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.2s;
        }
        
        .clause-library-wrapper .tab:hover {
            background: #D4E4F4;
            color: 1A56A3;
        }
        
        .clause-library-wrapper .tab.active {
            background: white;
            color: #1A56A3;
            border-bottom: 3px solid #1A56A3;
        }
        
        .clause-library-wrapper .tab-content {
            display: none;
            flex: 1;
            min-height: 0;
            overflow: hidden;
        }
        
        .clause-library-wrapper .tab-content.active {
            display: flex;
            flex-direction: column;
        }
        
        /* Clause Editor Styles */
        .clause-library-wrapper .editor-layout {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0;
            flex: 1;
            min-height: 0;
            overflow: hidden;
            border-top: 1px solid #bdc3c7;
        }
        
        .clause-library-wrapper .panel {
            display: flex;
            flex-direction: column;
            border-right: 1px solid #bdc3c7;
            min-height: 0;
            overflow: hidden;
        }
        
        .clause-library-wrapper .panel:last-child {
            border-right: none;
        }
        
        .clause-library-wrapper .panel-header {
            background: #2667C1;
            color: white;
            padding: 15px 20px;
            font-weight: 600;
            font-size: 14px;
            border-bottom: 1px solid #1A56A3;
            display: flex;
            align-items: center;
            gap: 15px;
            min-height: 50px;
            box-sizing: border-box;
        }
        
        .clause-library-wrapper .panel-content {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            overflow-x: visible;
            padding: 20px;
            padding-bottom: 20px;
        }
        
        .clause-library-wrapper .markdown-editor {
            width: 100%;
            height: 100%;
            font-family: 'Courier New', monospace;
            font-size: 13px;
            line-height: 1.6;
            background: #f8f9fa;
            color: #1A56A3;
            border: none;
            padding: 20px;
            resize: none;
            box-sizing: border-box;
            tab-size: 4;
        }
        
        .clause-library-wrapper .markdown-editor:focus {
            outline: 2px solid #1A56A3;
            background: white;
        }
        
        .clause-library-wrapper .html-panel .panel-content,
        .html-panel {
            line-height: 1.6;
            color: #333;
        }
        
        .clause-library-wrapper .html-panel .panel-content {
            overflow-x: visible;
        }
        
        .clause-library-wrapper .html-panel .panel-content h1,
        .clause-library-wrapper .html-panel .panel-content h2,
        .clause-library-wrapper .html-panel .panel-content h3 {
            margin-top: 20px;
            margin-bottom: 10px;
            color: #1A56A3;
        }
        
        .clause-library-wrapper .html-panel .panel-content p {
            margin-bottom: 10px;
        }
        
        .clause-library-wrapper .html-panel .panel-content ul,
        .clause-library-wrapper .html-panel .panel-content ol {
            margin-bottom: 15px;
            padding-left: 0;
            list-style: none;
            overflow: visible;
        }
        
        .clause-library-wrapper .html-panel .panel-content li {
            margin-bottom: 5px;
            overflow: visible;
            position: relative;
        }
        
        .clause-library-wrapper .html-panel .panel-content .list-marker {
            display: inline-block;
            margin-right: 8px;
        }
        
        .clause-library-wrapper .html-panel .panel-content .clause-list {
            padding-left: 0;
            margin-left: 0;
        }
        /* PDF-accurate preview styling - UNIFIED for both editor and modal */
.clause-library-wrapper .html-panel .panel-content,
.clause-library-wrapper #modalPreview {
    font-family: Arial, sans-serif !important;
    font-size: 11pt !important;
    line-height: 1.5 !important;
    color: #333 !important;
}

.clause-library-wrapper .html-panel .panel-content h1,
.clause-library-wrapper #modalPreview h1 {
    font-size: 14pt !important;
    font-weight: bold !important;
    margin: 12pt 0 6pt 0 !important;
    color: #000 !important;
}

.clause-library-wrapper .html-panel .panel-content h2,
.clause-library-wrapper #modalPreview h2 {
    font-size: 12pt !important;
    font-weight: bold !important;
    margin: 10pt 0 5pt 0 !important;
    color: #000 !important;
}

.clause-library-wrapper .html-panel .panel-content h3,
.clause-library-wrapper #modalPreview h3 {
    font-size: 11pt !important;
    font-weight: bold !important;
    margin: 8pt 0 4pt 0 !important;
    color: #000 !important;
}

.clause-library-wrapper .html-panel .panel-content p,
.clause-library-wrapper #modalPreview p {
    margin: 0 0 6pt 0 !important;
    line-height: 1.5 !important;
}

/* Keep indents for nesting, but hide default browser markers */
.clause-library-wrapper .html-panel .panel-content ul,
.clause-library-wrapper #modalPreview ul {
    margin: 6pt 0 !important;
    padding-left: 20pt !important;
    list-style-type: none !important;
}

.clause-library-wrapper .html-panel .panel-content ol,
.clause-library-wrapper #modalPreview ol {
    margin: 6pt 0 !important;
    padding-left: 20pt !important;
    list-style-type: decimal !important;
}

/* Hide numbers only for OLs with custom markers */
.clause-library-wrapper .html-panel .panel-content ol:has(.list-marker),
.clause-library-wrapper #modalPreview ol:has(.list-marker) {
    list-style-type: none !important;
}

.clause-library-wrapper .html-panel .panel-content li,
.clause-library-wrapper #modalPreview li {
    margin: 3pt 0 !important;
}

.clause-library-wrapper .html-panel .panel-content strong,
.clause-library-wrapper .html-panel .panel-content b,
.clause-library-wrapper #modalPreview strong,
.clause-library-wrapper #modalPreview b {
    font-weight: bold !important;
}

.clause-library-wrapper .html-panel .panel-content em,
.clause-library-wrapper .html-panel .panel-content i,
.clause-library-wrapper #modalPreview em,
.clause-library-wrapper #modalPreview i {
    font-style: italic !important;
}
        
        .clause-library-wrapper .controls {
            padding: 15px 20px;
            background: #ecf0f1;
            border-bottom: 1px solid #bdc3c7;
            display: flex;
            gap: 10px;
            align-items: center;
            flex-wrap: wrap;
        }
        
        .clause-library-wrapper .controls select {
            padding: 8px 12px;
            border: 1px solid #bdc3c7;
            border-radius: 4px;
            font-size: 14px;
        }
        
        .clause-library-wrapper .controls button {
            padding: 8px 16px;
            background: #1A56A3;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
        }
        
        .clause-library-wrapper .controls button:hover {
            background: #2980b9;
        }
        
        .clause-library-wrapper .controls button.secondary {
            background: #95a5a6;
        }
        
        .clause-library-wrapper .controls button.secondary:hover {
            background: #7f8c8d;
        }
        
        .clause-library-wrapper .checkbox-label {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
            color: #1A56A3;
        }
        
        /* Clause Set Builder Styles */
        .clause-library-wrapper .set-builder-layout {
            display: grid;
            grid-template-columns: 400px 1fr;
            gap: 0;
            flex: 1;
            min-height: 0;
            overflow: hidden;
            border-top: 1px solid #bdc3c7;
        }
        
        .clause-library-wrapper .search-panel {
            border-right: 1px solid #bdc3c7;
            display: flex;
            flex-direction: column;
            min-height: 0;
            overflow: hidden;
        }
        
        .clause-library-wrapper .search-box {
            padding: 15px;
            border-bottom: 1px solid #bdc3c7;
        }
        
        .clause-library-wrapper .search-box input {
            width: 100%;
            padding: 10px;
            border: 1px solid #bdc3c7;
            border-radius: 4px;
            font-size: 14px;
        }
        
        .clause-library-wrapper .clause-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
            padding-bottom: 10px;
        }
        
        .clause-library-wrapper .clause-item {
            padding: 12px;
            margin-bottom: 8px;
            background: #f8f9fa;
            border: 1px solid #e0e0e0;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .clause-library-wrapper .clause-item:hover {
            background: #e8f4f8;
            border-color: #1A56A3;
        }
        
        .clause-library-wrapper .clause-item-title {
            font-weight: 600;
            color: #1A56A3;
            margin-bottom: 4px;
        }
        
        .clause-library-wrapper .clause-item-id {
            font-size: 12px;
            color: #7f8c8d;
        }
        
        .clause-library-wrapper .set-panel {
            display: flex;
            flex-direction: column;
            min-height: 0;
            overflow: hidden;
        }
        
        .clause-library-wrapper .set-controls {
            padding: 15px;
            background: #ecf0f1;
            border-bottom: 1px solid #bdc3c7;
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .clause-library-wrapper .set-controls button {
            padding: 8px 16px !important;
            background: #1A56A3 !important;
            color: white !important;
            border: none !important;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px !important;
        }
        
        .clause-library-wrapper .set-controls button:hover {
            background: #144580 !important;
        }
        
        .clause-library-wrapper .set-controls button.secondary {
            background: #6C8FC1 !important;
        }
        
        .clause-library-wrapper .set-controls button.secondary:hover {
            background: #5A7BAD !important;
        }
        
        .clause-library-wrapper .set-controls input {
            flex: 1;
            padding: 8px 12px;
            border: 1px solid #bdc3c7;
            border-radius: 4px;
            font-size: 14px;
        }
        
        .clause-library-wrapper .set-list {
            flex: 1;
            overflow-y: auto;
            padding: 15px;
            padding-bottom: 15px;
        }
        
        .clause-library-wrapper .set-item {
            padding: 15px;
            margin-bottom: 10px;
            background: white;
            border: 2px solid #e0e0e0;
            border-radius: 4px;
            display: flex;
            align-items: center;
            gap: 15px;
            cursor: move;
            transition: all 0.2s;
        }
        
        .clause-library-wrapper .set-item:hover {
            border-color: #1A56A3;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        
        .clause-library-wrapper .set-item.dragging {
            opacity: 0.5;
            border-color: #1A56A3;
        }
        
        .clause-library-wrapper .drag-handle {
            cursor: grab;
            color: #7f8c8d;
            font-size: 18px;
            user-select: none;
        }
        
        .clause-library-wrapper .drag-handle:active {
            cursor: grabbing;
        }
        
        .clause-library-wrapper .set-item-content {
            flex: 1;
        }
        
        .clause-library-wrapper .set-item-title {
            font-weight: 600;
            color: #1A56A3;
            margin-bottom: 4px;
        }
        
        .clause-library-wrapper .set-item-id {
            font-size: 12px;
            color: #7f8c8d;
        }
        
        .clause-library-wrapper .set-item-actions {
            display: flex;
            gap: 5px;
        }
        
        .clause-library-wrapper .set-item-actions button {
            padding: 6px 12px;
            font-size: 12px;
        }
        
        .clause-library-wrapper .status {
            padding: 10px 15px;
            background: #d4edda;
            color: #155724;
            border-radius: 4px;
            margin: 10px 15px;
            font-size: 14px;
        }
        
        /* Modal Styles */
        .clause-library-wrapper .modal {
            display: none;
            position: fixed;
            z-index: 100000 !important;  /* Higher z-index for WordPress */
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.5);
            align-items: center;
            justify-content: center;
        }

        /* When modal is shown via style.display = 'flex' */
        .clause-library-wrapper .modal.active,
        .clause-library-wrapper .modal[style*="display: flex"],
        .clause-library-wrapper .modal[style*="display:flex"] {
            display: flex !important;
        }
                
                .clause-library-wrapper .modal-content {
                    background-color: white;
                    border-radius: 8px;
                    width: 90%;
                    max-width: 1200px;
                    max-height: 90vh;
                    display: flex;
                    flex-direction: column;
                    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
                }
        
        .clause-library-wrapper .modal-header {
            padding: 20px;
            background: #1A56A3;
            color: white;
            border-radius: 8px 8px 0 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .clause-library-wrapper .modal-header h2 {
            margin: 0;
            font-size: 20px;
            color: white !important;  /* ADD THIS */
        }
        
        .clause-library-wrapper .modal-close {
            background: none;
            border: none;
            color: white;
            font-size: 24px;
            cursor: pointer;
            padding: 0;
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .clause-library-wrapper .modal-close:hover {
            background: rgba(255,255,255,0.1);
            border-radius: 4px;
        }
        
        .clause-library-wrapper .modal-body {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            padding-bottom: 20px;
        }
