.source-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2200000000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.source-preview-modal a { pointer-events: none; }
.source-preview-modal svg {
	height: auto;
	max-width: 64px;
	max-height: 32px;
	object-fit: contain;
}
.source-preview-modal img {
	height: auto;
	max-width: 50%;
	max-height: 160px;
	object-fit: contain;
	border-radius: 8px;
	mix-blend-mode: multiply;
}

.source-preview-modal.active {
    opacity: 1;
    visibility: visible;
}

.source-preview-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.source-preview-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-height: 90vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.source-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.source-preview-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: #2c3e50;
}

.source-preview-title img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

.source-preview-close {
	padding: 0;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.source-preview-close:hover {
    background-color: #e9ecef;
    color: #495057;
}

.source-preview-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    line-height: 1.6;
    color: #2c3e50;
    overscroll-behavior: contain;
}

.source-preview-content h1,
.source-preview-content h2,
.source-preview-content h3,
.source-preview-content h4,
.source-preview-content h5,
.source-preview-content h6 {
    margin: 24px 0 12px;
    color: #2c3e50;
}

.source-preview-content h1 { font-size: 1.5em; }
.source-preview-content h2 { font-size: 1.3em; }
.source-preview-content h3 { font-size: 1.1em; }

.source-preview-content p {
    margin: 0.75em 0;
}

.source-preview-content a {
    color: #3498db;
    text-decoration: none;
}

.source-preview-content a:hover {
    text-decoration: underline;
}

.source-preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 10px 0;
}

.source-preview-content ul,
.source-preview-content ol {
    margin: 0.75em 0;
    padding-left: 2em;
}

.source-preview-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.source-preview-content th,
.source-preview-content td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.source-preview-content th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.source-preview-content blockquote {
    border-left: 4px solid #3498db;
    margin: 1em 0;
    padding: 10px 20px;
    background-color: #f8f9fa;
    font-style: italic;
}

.source-preview-content pre,
.source-preview-content code {
    background-color: #f4f4f4;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.source-preview-content pre {
    padding: 12px;
    overflow-x: auto;
    margin: 1em 0;
}

.source-preview-content code {
    padding: 2px 4px;
}

.source-preview-citations {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    gap: 4px;
    width: 100%;
}
.source-preview-citations a {
    padding: 2px 8px;
    font-weight: 400;
    font-size: 12px;
    color: #3498db;
    text-decoration: none;
    border: 1px solid #3498db;
    border-radius: 6px;
    transition: all 0.2s ease;
	pointer-events: all;
    max-width: 50%;
    white-space: nowrap;
    overflow: hidden;
}

.source-preview-footer {
	display: flex;
    flex-flow: row wrap;
	justify-content: end;
    gap: 6px;
    padding: 16px 20px;
    border-top: 1px solid #e1e5e9;
    background: #f8f9fa;
    text-align: right;
}
.aai-sources .aai-search-ai.aai-disabled {
    pointer-events: none;
    opacity: 0.6;
}
.aai-sources .aai-search-ai { color: hsla(0, 0%, 100%, 0.6); font-weight: 400; }
.aai-sources .aai-search-ai span { color: white; font-weight: 700; }
.aai-sources .aai-search-ai svg {
    width: 20px;
    height: 20px;
    margin-right: 6px;
    vertical-align: middle;
    fill: transparent;
    stroke: white;
}
.aai-sources .aai-search-ai .svg-loader {
    fill: white;
    stroke: transparent;
}

.source-preview-footer .aai-save-changesX {
	display: none;
}
.source-preview-footer a {
}

.source-preview-footer a:hover {
    background-color: #3498db;
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .source-preview-container {
        width: 95%;
        max-height: 95vh;
    }
    
    .source-preview-header,
    .source-preview-content,
    .source-preview-footer {
        padding: 12px 16px;
    }
}



.aai-sources .aai-search-clear {
    font-size: 32px;
    padding: 1px 24px;
}
.aai-sources .aai-search-result-button:empty { display: none; }
.aai-sources .aai-search-result-button { background: white; }
.aai-sources .aai-search-result-button:hover { color: var(--aai-colorA); }






