/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 30px rgba(0,0,0,0.2);
}

/* Header */
.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 15px 20px;
    text-align: center;
    position: relative;
}

.header h1 {
    font-size: 1.5em;
    margin-bottom: 5px;
    font-weight: 700;
}

.header p {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.session-info {
    background: rgba(255,255,255,0.1);
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-family: monospace;
    flex-wrap: wrap;
}

.question-progress {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 15px;
    font-weight: bold;
    border: 1px solid rgba(255,255,255,0.3);
}

/* Content */
.content {
    padding: 15px 20px;
}

/* Instructions */
.instructions {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #2196F3;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.instructions h3 {
    color: #1976D2;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.instructions ul {
    margin-left: 15px;
    font-size: 0.9em;
}

.instructions li {
    margin-bottom: 5px;
    color: #555;
}

/* Color Legend */
.color-legend {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 2px solid #e9ecef;
}

.color-legend h4 {
    margin-bottom: 10px;
    color: #495057;
    font-size: 1em;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.legend-label {
    font-weight: 600;
    font-family: monospace;
    font-size: 0.9em;
}

/* Stats Panel */
.stats-panel {
    display: flex;
    justify-content: space-around;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 1.5em;
    font-weight: bold;
    color: #2196F3;
    display: block;
}

.stat-label {
    color: #666;
    font-size: 0.8em;
    margin-top: 3px;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 30px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 6px;
}

/* Reference Section */
.reference-section {
    margin-bottom: 15px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    padding: 15px;
    border: 2px solid #dee2e6;
}

.reference-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 10px;
}

.reference-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.reference-subtitle {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: white;
    padding: 8px 15px;
    margin: 0;
    font-size: 0.9em;
    font-weight: 600;
}

.reference-container {
    padding: 10px;
    background: #f8f9fa;
    line-height: 1.4;
    border: 2px solid #e9ecef;
    border-top: none;
    min-height: 80px;
    font-size: 0.8em;
}

.reference-container .fact-tag {
    cursor: default;
    opacity: 0.9;
}

.reference-container .fact-tag:hover {
    transform: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Annotation Sections */
.annotation-section {
    margin-bottom: 15px;
}

.annotation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 10px;
}

.annotation-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 2px solid #28a745;
}

.annotation-subtitle {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 8px 15px;
    margin: 0;
    font-size: 0.9em;
    font-weight: 600;
}

.section-title {
    font-size: 1.2em;
    color: #2c3e50;
    margin-bottom: 10px;
    padding: 8px 0;
    border-bottom: 2px solid #3498db;
    background: linear-gradient(90deg, transparent 0%, rgba(52, 152, 219, 0.1) 100%);
}

.text-container {
    background: #ffffff;
    padding: 12px;
    border-radius: 6px;
    border: 2px solid #e9ecef;
    margin-bottom: 10px;
    line-height: 1.4;
    font-size: 0.85em;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    min-height: 80px;
}

.text-container:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

/* Fact Tags - Dynamic Colors */
.fact-tag {
    padding: 4px 10px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: inline-block;
    margin: 2px;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.fact-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    filter: brightness(1.1);
}

.fact-tag.selected {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.5);
    border-color: #2196F3;
    z-index: 10;
}

.fact-tag.edited {
    position: relative;
}

.fact-tag.edited::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    background: #4CAF50;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

/* Editing Panel */
.editing-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 1000;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    display: none;
    animation: modalSlideIn 0.3s ease;
}

.editing-panel.active {
    display: block;
}

@keyframes modalSlideIn {
    from { 
        opacity: 0; 
        transform: translate(-50%, -60%); 
    }
    to { 
        opacity: 1; 
        transform: translate(-50%, -50%); 
    }
}

.panel-header {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 20px 25px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h4 {
    font-size: 1.3em;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.panel-content {
    padding: 25px;
}

.fact-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.fact-id-label {
    font-weight: bold;
    color: #666;
}

.fact-id-value {
    font-family: monospace;
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.fact-color-preview {
    width: 30px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.panel-content label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
}

.original-text {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    margin-bottom: 15px;
    font-style: italic;
    color: #666;
}

.edit-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 20px;
    transition: border-color 0.3s;
    resize: vertical;
    min-height: 80px;
}

.edit-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.panel-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Notes Section */
.notes-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 2px solid #e9ecef;
}

.notes-section h3 {
    color: #495057;
    margin-bottom: 15px;
}

.notes-section textarea {
    width: 100%;
    min-height: 100px;
    padding: 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1em;
    resize: vertical;
    transition: border-color 0.3s;
}

.notes-section textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Submit Section */
.submit-section {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin-top: 30px;
}

.submit-section h3 {
    margin-bottom: 15px;
    font-size: 1.4em;
}

.submit-section p {
    margin-bottom: 25px;
    opacity: 0.9;
}

.submit-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.submit-btn {
    background: white;
    color: #27ae60;
    padding: 18px 40px;
    border: none;
    border-radius: 12px;
    font-size: 1.3em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.submit-btn:disabled {
    background: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.report-btn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 18px 30px;
    border: none;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.report-btn:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.report-btn:disabled {
    background: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.submission-status {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    display: none;
}

.submission-status.success {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    display: block;
}

.submission-status.error {
    background: rgba(231, 76, 60, 0.2);
    border: 2px solid rgba(231, 76, 60, 0.3);
    display: block;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    font-size: 1.2em;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 0;
    }
    
    .content {
        padding: 20px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .stats-panel {
        flex-direction: column;
        gap: 20px;
    }
    
    .legend-items {
        justify-content: center;
    }
    
    .reference-grid,
    .annotation-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .reference-section {
        padding: 15px;
    }
    
    .editing-panel {
        width: 95%;
        margin: 20px;
    }
    
    .panel-actions {
        flex-direction: column;
    }
}

/* Modal Backdrop */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}

.modal-backdrop.active {
    display: block;
}

/* Selection Toolbar */
.selection-toolbar {
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    padding: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
    border: 2px solid #e9ecef;
    animation: toolbarSlideIn 0.2s ease;
}

@keyframes toolbarSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toolbar-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-add {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

.btn-add:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-split {
    background: linear-gradient(135deg, #ff9800, #f57c00);
}

.btn-split:hover {
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.btn-extract {
    background: linear-gradient(135deg, #9c27b0, #7b1fa2);
}

.btn-extract:hover {
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
}

.btn-merge {
    background: linear-gradient(135deg, #2196f3, #1976d2);
}

.btn-merge:hover {
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.btn-close {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    min-width: 32px;
    padding: 8px;
}

.btn-close:hover {
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

/* Text Selection Enhancement */
.text-container {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.text-container::selection {
    background: rgba(33, 150, 243, 0.3);
}

.text-container::-moz-selection {
    background: rgba(33, 150, 243, 0.3);
}

/* Enhanced fact tag styling for selection */
.fact-tag {
    position: relative;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.fact-tag::selection {
    background: rgba(255, 255, 255, 0.3);
}

.fact-tag::-moz-selection {
    background: rgba(255, 255, 255, 0.3);
}

/* Fact ID Labels */
.fact-tag-with-id {
    position: relative;
    padding-top: 12px; /* Add space for the ID label */
}

.fact-id-label {
    position: absolute;
    top: -8px;
    left: -2px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 9px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1;
    z-index: 10;
    pointer-events: none;
    font-family: monospace;
    letter-spacing: 0.5px;
    transition: opacity 0.3s ease;
}

/* Show ID label on hover for better visibility */
.fact-tag-with-id:hover .fact-id-label {
    opacity: 1;
    background: rgba(0, 0, 0, 0.95);
    transform: scale(1.1);
}

/* Adjust margins to prevent overlap */
.fact-tag-with-id + .fact-tag-with-id {
    margin-left: 4px;
}

/* Fact ID Choice Modal */
.fact-id-choice-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fact-id-choice-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from { 
        opacity: 0; 
        transform: translateY(30px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.fact-id-choice-header {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    padding: 20px 25px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fact-id-choice-header h3 {
    margin: 0;
    font-size: 1.3em;
}

.fact-id-choice-body {
    padding: 25px;
}

.fact-id-choice-body p {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.fact-id-options {
    margin-bottom: 25px;
}

.fact-id-option {
    margin-bottom: 15px;
}

.fact-id-option input[type="radio"] {
    display: none;
}

.fact-id-option label {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.fact-id-option label:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.fact-id-option input[type="radio"]:checked + label {
    border-color: #3498db;
    background: linear-gradient(135deg, #e3f2fd, #f3e5f5);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.option-icon {
    font-size: 1.5em;
    margin-right: 15px;
}

.option-text {
    flex: 1;
    line-height: 1.4;
}

.option-text strong {
    color: #2c3e50;
}

.option-text small {
    color: #666;
}

.color-preview {
    width: 30px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
    margin-left: 10px;
}

.existing-fact-list {
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
}

.existing-fact-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background 0.3s ease;
}

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

.existing-fact-item:hover {
    background: #e3f2fd;
}

.existing-fact-item.selected {
    background: #3498db;
    color: white;
}

.fact-color-preview {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
    margin-right: 12px;
}

.fact-id {
    font-family: monospace;
    font-weight: bold;
    margin-right: 15px;
    min-width: 60px;
}

.fact-sample {
    flex: 1;
    color: #666;
    font-size: 0.9em;
}

.existing-fact-item.selected .fact-sample {
    color: rgba(255,255,255,0.9);
}

/* Custom Fact Input */
.custom-fact-input {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.custom-fact-input label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
}

.custom-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.fact-prefix {
    font-family: monospace;
    font-weight: bold;
    color: #495057;
    background: #e9ecef;
    padding: 8px 12px;
    border-radius: 4px 0 0 4px;
    border: 2px solid #dee2e6;
    border-right: none;
}

.custom-input-row input[type="number"] {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 0;
    font-size: 1em;
    font-family: monospace;
    font-weight: bold;
    min-width: 60px;
    max-width: 80px;
}

.custom-input-row input[type="number"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.color-preview-dynamic {
    width: 30px;
    height: 34px;
    border-radius: 0 4px 4px 0;
    border: 2px solid #dee2e6;
    border-left: none;
    transition: background-color 0.3s ease;
}

.custom-fact-preview {
    font-family: monospace;
    font-weight: bold;
    font-size: 1.1em;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 2px solid #dee2e6;
    text-align: center;
    transition: all 0.3s ease;
}

.fact-id-choice-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Accept/Reject Controls for Reference Section */
.fact-tag-with-controls {
    padding: 4px 8px;
    border-radius: 8px;
    border: 2px solid transparent;
    position: relative;
    display: inline-flex;
    align-items: center;
    margin: 2px;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

/* Add fact ID badge to reference section fact tags */
.fact-tag-with-controls::before {
    content: attr(data-fact-id);
    position: absolute;
    top: -8px;
    left: -2px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1;
    z-index: 10;
    pointer-events: none;
    font-family: monospace;
}

.fact-tag-with-controls:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.fact-tag-with-controls.accepted {
    opacity: 0.5;
    transform: scale(0.95);
    filter: grayscale(50%);
}

.fact-tag-with-controls.rejected {
    opacity: 0.3;
    transform: scale(0.9);
    filter: grayscale(80%);
    text-decoration: line-through;
}

.fact-content {
    flex: 1;
    margin-right: 8px;
}

.fact-controls {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.accept-btn, .reject-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.accept-btn {
    color: #27ae60;
}

.accept-btn:hover {
    background: #27ae60;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

.reject-btn {
    color: #e74c3c;
}

.reject-btn:hover {
    background: #e74c3c;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.accept-btn:active, .reject-btn:active {
    transform: scale(0.95);
}

.accept-btn.clicked {
    background: #27ae60;
    color: white;
    animation: acceptPulse 0.3s ease;
}

.reject-btn.clicked {
    background: #e74c3c;
    color: white;
    animation: rejectPulse 0.3s ease;
}

@keyframes acceptPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); background: #2ecc71; }
    100% { transform: scale(1); }
}

@keyframes rejectPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); background: #f44336; }
    100% { transform: scale(1); }
}

/* Dim but keep accessible controls when fact is accepted/rejected */
.fact-tag-with-controls.accepted .fact-controls,
.fact-tag-with-controls.rejected .fact-controls {
    opacity: 0.6;
    /* Keep pointer-events enabled so they can be clicked again */
}

/* Make controls more visible on hover for accepted/rejected items */
.fact-tag-with-controls.accepted:hover .fact-controls,
.fact-tag-with-controls.rejected:hover .fact-controls {
    opacity: 1;
}

/* Add a success indicator for accepted facts */
.fact-tag-with-controls.accepted::after {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    background: #27ae60;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    z-index: 10;
}

/* Add a reject indicator for rejected facts */
.fact-tag-with-controls.rejected::after {
    content: '✗';
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    z-index: 10;
}

/* Status Indicators */
.accept-status {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(39, 174, 96, 0.95);
    color: white;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: bold;
    z-index: 3000;
    animation: statusFadeInOut 1.5s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.reject-status {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(231, 76, 60, 0.95);
    color: white;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: bold;
    z-index: 3000;
    animation: statusFadeInOut 1.5s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

@keyframes statusFadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .fact-id-choice-content {
        width: 95%;
        margin: 20px;
    }
    
    .fact-id-choice-header {
        padding: 15px 20px;
    }
    
    .fact-id-choice-body {
        padding: 20px;
    }
    
    .fact-id-choice-actions {
        flex-direction: column;
    }
    
    .existing-fact-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .fact-id {
        min-width: auto;
    }
    
    /* Adjust accept/reject buttons for mobile */
    .accept-btn, .reject-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .fact-controls {
        gap: 6px;
        margin-left: 10px;
    }
}
