* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.disclaimer-banner {
    margin-top: 14px;
    margin-bottom: 18px;
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid #c0392b;
    background: #fdecea;
    color: #c0392b;
    font-size: 14px;
    line-height: 1.5;
}

.contact-box {
    margin-bottom: 18px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #d0d7de;
    background: #f6f8fa;
    color: #24292f;
    font-size: 13px;
    line-height: 1.5;
}

.contact-box-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.contact-box-row {
    margin-bottom: 4px;
}

.contact-link,
.contact-link:visited {
    color: #0969da;
    text-decoration: none;
}

.substack-link,
.substack-link:visited {
    color: #0969da;
    font-weight: 600;
    text-decoration: none;
}

h1 {
    color: #2c3e50;
    margin-bottom: 20px;
}

.search-section {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.filter-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: #ecf0f1;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    box-sizing: border-box;
}

.filter-btn.active {
    background: #3498db;
    color: white;
}

.filter-btn:hover {
    background: #bdc3c7;
}

.filter-btn.active:hover {
    background: #2980b9;
}

.graph-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: #ecf0f1;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    text-decoration: none;
    color: #2c3e50;
    display: inline-block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    box-sizing: border-box;
    text-align: center;
}

.graph-btn:hover {
    background: #bdc3c7;
}

.stats {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: #7f8c8d;
}

.filter-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ecf0f1;
}

.filter-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-control label {
    font-size: 13px;
    font-weight: 500;
    color: #2c3e50;
    white-space: nowrap;
}

.filter-control input {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.filter-control input:focus {
    outline: none;
    border-color: #3498db;
}

.main-content {
    height: calc(100vh - 250px);
}

.category-section {
    margin-bottom: 30px;
}

.category-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ecf0f1;
}

.definitions-dropdown {
    margin-bottom: 20px;
}

.definitions-dropdown label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 14px;
}

.definitions-dropdown select {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
}

.definitions-dropdown select:focus {
    outline: none;
    border-color: #3498db;
}

.relationship-item {
    cursor: pointer;
    transition: all 0.2s;
}

.relationship-item:hover {
    background: #f0f0f0;
    transform: translateX(2px);
}

.results-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* Allow tooltips (e.g., expert review) to render outside header/list bounds */
    overflow: visible;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.results-header {
    padding: 15px;
    background: #34495e;
    color: white;
    font-weight: 600;
    position: relative;
    z-index: 2;
}

.results-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Home layout: expand panel so you don't scroll inside it */
body.home-mode .main-content {
    height: auto !important;
}

body.home-mode .results-panel {
    height: auto !important;
}

body.home-mode .results-list {
    overflow-y: visible !important;
}

/* Home quick filters: collapse to single column on small screens */
@media (max-width: 800px) {
    .home-quick-filters {
        grid-template-columns: 1fr !important;
        gap: 10px;
        margin-bottom: 20px;
    }

    .home-quick-filters .filter-btn,
    .home-quick-filters .home-graph-btn {
        width: 100%;
        word-wrap: break-word;
        white-space: normal;
        text-align: center;
        padding: 12px 8px;
        font-size: 13px;
        line-height: 1.4;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Make results list less cramped */
    .results-list {
        padding: 8px;
    }

    .results-panel {
        margin-bottom: 12px;
    }

    /* Increase touch target for relationship items */
    .relationship-item {
        padding: 14px;
    }

    /* Adjust header spacing */
    header h1 {
        font-size: 20px;
    }

    /* Fix filter controls wrapping on mobile */
    .filter-controls {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
        width: 100%;
        overflow-x: hidden;
    }

    .filter-control {
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 12px;
        flex-wrap: wrap !important;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .filter-control label {
        white-space: normal !important;
        margin-bottom: 12px !important;
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-right: 0 !important;
        line-height: 1.4;
        word-wrap: break-word;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    /* Stack each input group on mobile - force wrapping */
    .filter-control>span,
    .filter-control .filter-input-label {
        display: block !important;
        margin-bottom: 8px !important;
        margin-right: 0 !important;
        white-space: normal !important;
        width: 100% !important;
        max-width: 100% !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    .filter-control input,
    .filter-control .filter-input {
        display: block !important;
        margin-bottom: 12px !important;
        margin-right: 0 !important;
        width: 80px !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Group label and input together */
    .filter-control .filter-input-label+.filter-input {
        margin-left: 0;
        margin-top: 4px;
    }

    /* Ensure header doesn't overflow */
    header {
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Add spacing to home intro sections */
    .home-intro-section {
        margin-bottom: 20px !important;
    }

    .home-intro {
        padding-bottom: 30px;
        margin-bottom: 20px;
    }

    /* Ensure home quick filters have proper spacing from content above */
    .home-quick-filters {
        margin-top: 20px !important;
        padding-top: 20px;
    }
}

.result-item {
    padding: 15px;
    border-bottom: 1px solid #ecf0f1;
    cursor: pointer;
    transition: background 0.2s;
}

.result-item:hover {
    background: #f8f9fa;
}

.result-item.selected {
    background: #e3f2fd;
    border-left: 4px solid #3498db;
}

.result-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
}

.result-type {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.result-type.construct {
    background: #e8f5e9;
    color: #2e7d32;
}

.result-type.measurement {
    background: #e3f2fd;
    color: #1565c0;
}

.result-type.behavior {
    background: #fce4ec;
    color: #c2185b;
}

.result-definition {
    font-size: 13px;
    color: #000000;
    margin-bottom: 8px;
    line-height: 1.5;
}

.result-papers {
    font-size: 11px;
    color: #95a5a6;
}

.visualization-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.viz-header {
    padding: 15px;
    background: #2c3e50;
    color: white;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.details-panel {
    padding: 20px;
    background: #f8f9fa;
    flex: 1;
    overflow-y: auto;
    height: 100%;
}

.details-header {
    font-weight: 600;
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 18px;
}

.relationship-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.relationship-item.construct {
    border-left-color: #4caf50;
}

.relationship-item.measurement {
    border-left-color: #2196f3;
}

.relationship-item.behavior {
    border-left-color: #e91e63;
}

.relationship-type {
    font-weight: 600;
    color: #3498db;
    margin-bottom: 5px;
}

.relationship-nodes {
    margin: 5px 0;
    font-size: 14px;
}

.relationship-evidence {
    font-size: 12px;
    color: #7f8c8d;
    font-style: italic;
    margin-top: 5px;
}

.relationship-paper {
    font-size: 11px;
    color: #95a5a6;
    margin-top: 5px;
}

/* Raw config (JSON) viewer */
.raw-config-section {
    margin-top: 24px;
}

.raw-config-toggle {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #ecf0f1;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

.raw-config-toggle:hover {
    background: #dde3e6;
}

.raw-config-content {
    max-height: 260px;
    overflow: auto;
    padding: 10px 12px;
    background: #111827;
    color: #e5e7eb;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 11px;
    border-radius: 6px;
    border: 1px solid #1f2937;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #95a5a6;
}

.home-intro {
    max-width: 900px;
    margin: 0 auto;
    text-align: left;
    color: #000000;
}

.home-intro-title {
    text-align: center;
    margin-bottom: 16px;
    color: #000000;
}

.home-intro-section {
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
}

.home-intro-section-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: #000000;
}

.home-intro-section p {
    margin: 0;
    color: #000000;
}

.empty-state h3 {
    margin-bottom: 10px;
    color: #7f8c8d;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #3498db;
}

.home-graph-button {
    display: inline-block;
    padding: 15px 30px;
    background: #3498db;
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    transition: background 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.home-graph-button:hover {
    background: #2980b9;
}

.home-quick-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 16px;
    justify-content: center;
    margin-top: 30px;
    align-items: center;
}

.home-quick-filters .filter-btn {
    width: 100%;
    justify-content: center;
}

.home-quick-filters .home-graph-btn {
    grid-column: 2;
    justify-self: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    text-align: center;
    box-sizing: border-box;
}

/* Footer */
.site-footer {
    margin-top: 16px;
    padding: 0 0 20px 0;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

.expert-flag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    border-radius: 50%;
    cursor: default;
}

.expert-flag.false {
    background: #fdecea;
    color: #c0392b;
}

.expert-flag.true {
    background: #e8f5e9;
    color: #2e7d32;
}

.expert-flag-wrap {
    position: relative;
    display: inline-block;
    margin-left: 6px;
    cursor: default;
    z-index: 10;
}

.expert-flag-tooltip {
    position: absolute;
    /* Show tooltip to the right of the badge to avoid header overlap */
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 10px;
    background: #2c3e50;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
    z-index: 9999;
}

.expert-flag-wrap:hover .expert-flag-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Details page (node view): place tooltip below the badge */
.details-expert-flag .expert-flag-tooltip {
    left: 0;
    top: calc(100% + 8px);
    transform: none;
}
