:root {
    --mondrian-black: #151713;
    --mondrian-gray: #d8dde2;
    --mondrian-gray-dark: #7a817f;
}

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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.1rem;
    color: #666;
    font-weight: 400;
}

/* Search Section */
.search-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.search-container {
    max-width: 600px;
    margin: 0 auto;
}

.search-input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #fff;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-btn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.search-btn:active {
    transform: translateY(0);
}

.example-users {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
}

.example-users span {
    margin-right: 0.5rem;
}

.example-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    margin: 0 0.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

.example-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.example-btn-started {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

.example-btn-finalized {
    background: #dcfce7;
    border-color: #16a34a;
    color: #166534;
}

.loading-indicator {
    text-align: center;
    padding: 1rem;
    color: #667eea;
    font-size: 1.1rem;
}

/* Results Section */
.results-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

/* Stats Panel */
.stats-panel {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e1e5e9;
}

.stats-panel h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: #333;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
}

.subreddits-section {
    margin-top: 1rem;
}

.subreddits-list {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.subreddit-tag {
    background: #f0f0f0;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #666;
}

/* Timeline */
.timeline-container h3 {
    margin-bottom: 1rem;
    color: #333;
}

.timeline-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.control-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.control-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.filter-panel {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.filter-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.filter-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Activity Timeline */
.activity-timeline {
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 1rem;
    min-width: 0;
}

.activity-item {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    position: relative;
    min-width: 0;
    max-width: 100%;
}

.activity-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
}

.activity-item.post {
    border-left: 4px solid #28a745;
}

.activity-item.comment {
    border-left: 4px solid #17a2b8;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.activity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    font-size: 0.9rem;
    color: #666;
    min-width: 0;
    flex: 1 1 auto;
}

.activity-type {
    background: #667eea;
    color: white;
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.activity-type.post {
    background: #28a745;
}

.activity-type.comment {
    background: #17a2b8;
}

.activity-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.activity-content {
    line-height: 1.7;
    color: #555;
    position: relative;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.activity-content.selectable {
    cursor: text;
}

.activity-content.selectable::after {
    content: "💬 Select text to annotate";
    position: absolute;
    top: -25px;
    right: 0;
    font-size: 0.8rem;
    color: #999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.activity-content.selectable:hover::after {
    opacity: 1;
}

.context-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 3px solid #667eea;
}

.context-title {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.context-content {
    color: #666;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Parent context / thread blocks injected under activity items */
.thread-context {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    box-sizing: border-box;
}

.thread-context .original-post-context > div[style*="display: flex"],
.thread-context .chain-comment-context > div[style*="display: flex"],
.thread-context .parent-comment-context > div[style*="display: flex"] {
    flex-wrap: wrap;
}

.annotations-indicator {
    background: #ff6b6b;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

/* Annotations Panel */
.annotations-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.annotations-panel.open {
    right: 0;
}

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

.panel-header h3 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #666;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #e9ecef;
    color: #333;
}

.annotations-list {
    padding: 1rem;
}

.annotation-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 3px solid #667eea;
}

.annotation-text {
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.annotation-meta {
    font-size: 0.8rem;
    color: #666;
}

.selected-text {
    background: #fff3cd;
    padding: 0.5rem;
    border-radius: 4px;
    font-style: italic;
    margin-bottom: 0.5rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal.modal--tutorial {
    max-width: 720px;
    width: calc(100% - 2rem);
}

.modal.modal--tutorial .tutorial-body {
    max-height: min(70vh, 560px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 0.25rem;
}

.tutorial-intro {
    color: #475569;
    line-height: 1.65;
    margin: 0 0 1.25rem 0;
    font-size: 0.95rem;
}

.tutorial-stage {
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    background: #f8fafc;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.tutorial-stage:last-of-type {
    margin-bottom: 0;
}

.tutorial-stage h4 {
    margin: 0 0 0.5rem 0;
    color: #1e293b;
    font-size: 0.95rem;
    font-weight: 600;
}

.tutorial-stage p {
    margin: 0;
    color: #475569;
    line-height: 1.6;
    font-size: 0.92rem;
}

.tutorial-stage p + p,
.tutorial-stage p + ul,
.tutorial-stage p + div {
    margin-top: 0.6rem;
}

.tutorial-legend {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tutorial-legend li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0 0 0.4rem 0;
    color: #475569;
    line-height: 1.6;
    font-size: 0.92rem;
}

.tutorial-legend li:last-child {
    margin-bottom: 0;
}

.tutorial-legend-swatch {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 3px;
    flex-shrink: 0;
}

.tutorial-legend-swatch--none {
    background: #fff;
    border: 1px solid #94a3b8;
}

.tutorial-legend-swatch--yellow {
    background: #ffc107;
}

.tutorial-legend-swatch--red {
    background: #dc3545;
}

.tutorial-anchor-caption {
    font-style: italic;
    color: #64748b;
    font-size: 0.85rem;
}

.tutorial-anchor-tables {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tutorial-anchor-table {
    border-collapse: collapse;
    flex: 1 1 220px;
    font-size: 0.85rem;
}

.tutorial-anchor-table caption {
    text-align: left;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.3rem;
    caption-side: top;
}

.tutorial-anchor-table th,
.tutorial-anchor-table td {
    border: 1px solid #e2e8f0;
    padding: 0.3rem 0.5rem;
    text-align: left;
    color: #475569;
}

.tutorial-anchor-table th {
    background: #f1f5f9;
    width: 1.5rem;
    text-align: center;
}

.tutorial-glossary-intro {
    margin: 0 0 1rem 0;
    color: #64748b;
    line-height: 1.6;
    font-size: 0.88rem;
}

.tutorial-glossary-list {
    margin: 0;
    padding: 0;
}

.tutorial-glossary-list dt {
    margin: 0.85rem 0 0.35rem 0;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.92rem;
}

.tutorial-glossary-list dt:first-child {
    margin-top: 0;
}

.tutorial-glossary-list dd {
    margin: 0;
    padding: 0;
    color: #475569;
    line-height: 1.6;
    font-size: 0.92rem;
}

.tutorial-footnote {
    margin: 1.25rem 0 0 0;
    font-size: 0.8rem;
    color: #64748b;
    font-style: italic;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e1e5e9;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.modal-body {
    padding: 1.5rem;
}

.selected-text-display {
    margin-bottom: 1rem;
}

.selected-text-preview {
    background: #fff3cd;
    padding: 1rem;
    border-radius: 8px;
    font-style: italic;
    margin-top: 0.5rem;
    border-left: 3px solid #ffc107;
}

.annotation-input {
    margin-bottom: 1rem;
}

.annotation-input label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.annotation-input textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 100px;
}

.annotation-input textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #e1e5e9;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #e9ecef;
    color: #333;
}

/* Text Selection Highlight */
.text-highlight {
    background: linear-gradient(120deg, #a8edea 0%, #fed6e3 100%);
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.text-highlight:hover {
    background: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .search-input-group {
        flex-direction: column;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .annotations-panel {
        width: 100%;
        right: -100%;
    }
    
    .modal {
        margin: 1rem;
        min-width: auto;
        width: calc(100% - 2rem);
    }
    
    .timeline-controls {
        flex-wrap: wrap;
    }
    
    .activity-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Smooth Scrollbar */
.activity-timeline::-webkit-scrollbar {
    width: 8px;
}

.activity-timeline::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.activity-timeline::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.activity-timeline::-webkit-scrollbar-thumb:hover {
    background: #5a6fd8;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Annotation Dropdown Styles */
.annotation-options {
    margin-bottom: 1rem;
}

.annotation-options label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.options-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.option-item {
    background: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-weight: 500;
}

.option-item:hover {
    border-color: #667eea;
    background: #f0f2ff;
}

.option-item.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.option-item input[type="checkbox"] {
    display: none;
}

.suboptions-container {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.suboption-section {
    margin-bottom: 1.5rem;
}

.suboption-section:last-child {
    margin-bottom: 0;
}

.suboption-title {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.suboption-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.suboption-item {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suboption-item:hover {
    border-color: #667eea;
    background: #f0f2ff;
}

.suboption-item.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.suboption-item input[type="checkbox"] {
    display: none;
}

.additional-notes {
    margin-bottom: 1rem;
}

.additional-notes label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.additional-notes textarea {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 80px;
}

.additional-notes textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.annotation-summary {
    background: #e8f4f8;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 3px solid #17a2b8;
}

.annotation-summary h4 {
    font-size: 0.8rem;
    margin: 0.5rem 0 0.3rem 0;
    color: #495057;
    font-weight: 600;
}

.annotation-summary h4:first-child {
    margin-top: 0;
}

.selected-categories, .selected-subcategories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.category-tag, .subcategory-tag {
    background: #17a2b8;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

.subcategory-tag {
    background: #6c757d;
}

.annotation-notes {
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.3rem;
    font-style: italic;
    color: #666;
}

/* Severity Buttons and Tags */
.suboption-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    width: 100%;
}

.suboption-text {
    font-size: 0.85rem;
    line-height: 1.4;
    color: #333;
}

.severity-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.severity-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.severity-btn:hover {
    transform: translateY(-1px);
}

.severity-btn.severity-potentially-concerning {
    border-color: #ffc107;
    color: #856404;
}

.severity-btn.severity-potentially-concerning:hover {
    background: #fff8e1;
}

.severity-btn.severity-potentially-concerning.selected {
    background: #ffc107;
    color: #000;
    border-color: #e0a800;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
}

.severity-btn.severity-concerning {
    border-color: #dc3545;
    color: #721c24;
}

.severity-btn.severity-concerning:hover {
    background: #fff5f5;
}

.severity-btn.severity-concerning.selected {
    background: #dc3545;
    color: white;
    border-color: #c82333;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
}

/* Severity Tags for Annotation Display */
.severity-potentially-concerning-tag {
    background: #ffc107 !important;
    color: #000 !important;
}

.severity-concerning-tag {
    background: #dc3545 !important;
    color: white !important;
}

/* Suboption item when selected */
.suboption-item.selected {
    background: #eef2f7;
    border-color: #17a2b8;
} 