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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #666;
    font-size: 1rem;
}

.search-container {
    position: relative;
    margin-bottom: 2rem;
}

#search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: #ff6b35;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.suggestions.active {
    display: block;
}

.suggestion-group {
    padding: 0.5rem 0;
}

.suggestion-group-title {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    background: #f9f9f9;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.suggestion-item:hover {
    background: #fff5f0;
}

.suggestion-item .type-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.suggestion-item .type-badge.user {
    background: #e3f2fd;
    color: #1976d2;
}

.suggestion-item .type-badge.post {
    background: #e8f5e9;
    color: #388e3c;
}

.suggestion-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-item .id {
    font-size: 0.8rem;
    color: #999;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top-color: #ff6b35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.results {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.source-info {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.source-info .label {
    color: #888;
    font-size: 0.9rem;
}

.source-info .source-name {
    font-weight: 600;
    font-size: 1.2rem;
    margin-left: 0.5rem;
}

.source-info .source-type {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    background: #f0f0f0;
    color: #666;
}

.columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .columns {
        grid-template-columns: 1fr;
    }
}

.column h2 {
    font-size: 1rem;
    color: #555;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #ff6b35;
}

.result-list {
    list-style: none;
}

.result-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    margin: 0 -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    border-radius: 4px;
}

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

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

.result-item .rank {
    width: 24px;
    height: 24px;
    background: #f0f0f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #666;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.result-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-item .score {
    font-size: 0.8rem;
    color: #888;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.substack-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #ff6b35;
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8rem;
    margin-left: 0.5rem;
    flex-shrink: 0;
    transition: background 0.2s;
}

.substack-link:hover {
    background: #e55a2b;
}

.stats {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.85rem;
    color: #888;
}

.no-results {
    text-align: center;
    padding: 2rem;
    color: #888;
}

/* Graph Button */
.graph-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    background: #ff6b35;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    margin-left: 0.75rem;
    vertical-align: middle;
}

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

/* Trust Graph Modal */
.graph-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.graph-modal-content {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    width: 95%;
    max-width: 1000px;
    max-height: 92vh;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.graph-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    transition: background 0.2s, color 0.2s;
}

.graph-modal-close:hover {
    background: #ff6b35;
    color: white;
}

.graph-modal-title {
    font-size: 1.25rem;
    color: #1a1a1a;
    margin-bottom: 1rem;
    padding-right: 2rem;
}

.graph-loading {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.graph-container {
    width: 100%;
    flex: 1;
    min-height: 500px;
    max-height: 700px;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
}

.graph-container svg {
    display: block;
}

.graph-error {
    text-align: center;
    padding: 3rem;
    color: #d32f2f;
}

/* Graph Legend */
.graph-legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #666;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.source {
    background: #ff6b35;
}

.legend-dot.user {
    background: #1976d2;
}

.legend-dot.post {
    background: #388e3c;
}

.legend-hint {
    font-style: italic;
    color: #999;
    margin-left: 0.5rem;
    padding-left: 0.5rem;
    border-left: 1px solid #ddd;
}

/* Graph Node Labels */
.node-label {
    fill: #333;
    pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .graph-modal-content {
        padding: 1rem;
        width: 95%;
    }

    .graph-container {
        height: 550px;
    }

    .graph-legend {
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .legend-hint {
        width: 100%;
        text-align: center;
        border-left: none;
        margin-left: 0;
        padding-left: 0;
        margin-top: 0.5rem;
    }
}
