:root {
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #c9d1d9;
    --muted: #8b949e;
    --green: #3fb950;
    --amber: #d29922;
    --red: #f85149;
    --blue: #58a6ff;
    --purple: #bc8cff;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'JetBrains Mono', 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
}

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

.terminal-header { text-align: center; margin-bottom: 30px; }
.site-name {
    color: var(--green);
    font-size: 24px;
    font-weight: bold;
    font-family: inherit;
}
.site-name-link { text-decoration: none; }
.site-name-link:hover .site-name { text-decoration: underline; }
.tagline { color: var(--muted); margin-top: 5px; font-size: 13px; }

/* Nav search bar (on all pages, under logo) */
.nav-search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}
.nav-search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}
.nav-search-input { flex: 1; }

/* Breadcrumbs */
.breadcrumbs {
    font-size: 12px;
    margin-bottom: 15px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}
.prompt { color: var(--green); white-space: nowrap; }
.search-input {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
}
.search-input:focus { outline: none; border-color: var(--blue); }
.terminal-select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px;
    font-family: inherit;
}

.stats-bar { margin-bottom: 20px; }
.muted { color: var(--muted); }

.repo-card {
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 12px;
    padding: 16px;
}
.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.repo-name { color: var(--blue); text-decoration: none; font-weight: bold; }
.repo-name:hover { text-decoration: underline; }
.owner-link { color: var(--purple); text-decoration: none; }
.owner-link:hover { text-decoration: underline; }
.repo-stars { color: var(--amber); }
.fork-icon {
    color: var(--muted);
}
.fork-icon::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 2px;
    vertical-align: -2px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='currentColor'><path d='M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z'/></svg>") center/contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='currentColor'><path d='M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z'/></svg>") center/contain no-repeat;
}
.review-author {
    margin-bottom: 8px;
    font-size: 12px;
    font-style: italic;
}
.repo-type-badge {
    margin-left: auto;
    padding: 2px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
}
.type-application { color: var(--green); border-color: var(--green); }
.type-data_research { color: var(--blue); border-color: var(--blue); }
.type-unknown { color: var(--muted); border-color: var(--muted); }

.repo-description { margin-bottom: 10px; color: var(--text); }
.repo-metrics { display: flex; gap: 20px; margin-bottom: 10px; flex-wrap: wrap; }
.metric { font-size: 12px; color: var(--muted); }
.rating-high { color: var(--green); }
.rating-medium { color: var(--amber); }
.rating-low { color: var(--red); }
.maint-active { color: var(--green); }
.maint-maintained { color: var(--green); }
.maint-stale { color: var(--amber); }
.maint-deprecated { color: var(--red); }
.maint-archived { color: var(--red); }
.drift-low { color: var(--green); }
.drift-medium { color: var(--amber); }
.drift-high { color: var(--red); }

.repo-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { color: var(--purple); font-size: 12px; }
.tag-link { text-decoration: none; }
.tag-link:hover { text-decoration: underline; color: var(--text); }
.components-toggle { margin-top: 8px; }

.repo-detail { margin-top: 20px; }
.repo-title { color: var(--green); font-size: 18px; margin-bottom: 10px; }
.detail-badges { display: flex; gap: 15px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.warning { color: var(--amber); }
.detail-section { margin-bottom: 25px; }
.section-label { color: var(--muted); margin-bottom: 10px; }
.detail-text { white-space: pre-wrap; }
.metric-row { display: flex; gap: 30px; flex-wrap: wrap; }

.terminal-footer {
    margin-top: 40px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 12px;
}
.terminal-link { color: var(--blue); text-decoration: none; }
.terminal-link:hover { text-decoration: underline; }
.no-results { padding: 20px; text-align: center; }

/* Tag cloud (browse mode) */
.tag-cloud-section { margin-bottom: 25px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.tag-cloud-link {
    color: var(--purple);
    text-decoration: none;
    font-size: 13px;
}
.tag-cloud-link:hover { text-decoration: underline; color: var(--text); }
.tag-count { color: var(--muted); font-size: 11px; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    padding: 15px 0;
}

/* Bar charts (repo detail) */
.chart-container { margin-top: 10px; }
.chart-title {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 8px;
    margin-top: 15px;
}
.chart-title-second { margin-top: 20px; }
.bar-chart { display: flex; flex-direction: column; gap: 4px; }
.bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.bar-label {
    min-width: 130px;
    text-align: right;
    color: var(--text);
    white-space: nowrap;
}
.bar-track {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    height: 16px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}
.bar-fill-count { background: var(--blue); }
.bar-fill-size { background: var(--green); }
.bar-value {
    min-width: 60px;
    color: var(--muted);
    font-size: 11px;
}

/* Review text (prominent, readable) */
.review-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
}
.review-intro { margin-bottom: 15px; font-size: 12px; }

/* Component findings (review-style, not file listing) */
.component-entry {
    border-left: 3px solid var(--blue);
    padding-left: 16px;
    margin-bottom: 20px;
}
.component-finding { margin-bottom: 8px; }
.component-summary {
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
}
.component-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
}
.component-link {
    color: var(--blue);
    text-decoration: none;
}
.component-link:hover { text-decoration: underline; }
.component-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.component-summary { color: var(--text); margin-top: 8px; }
.copy-btn {
    background: none; border: none; color: var(--muted);
    cursor: pointer; font-family: inherit; font-size: 12px;
}
.copy-btn:hover { color: var(--text); }

@media (max-width: 600px) {
    .terminal-container { padding: 10px; }
    .site-name { font-size: 18px; }
    .repo-metrics { gap: 10px; }
    .bar-label { min-width: 90px; }
}

/* Error page */
.error-page {
    text-align: center;
    padding: 60px 20px;
}

/* GitHub topics and dependency graph */
.topic-tag {
    background: rgba(88, 166, 255, 0.1);
    color: var(--blue);
    border: 1px solid rgba(88, 166, 255, 0.2);
}
.dep-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.dep-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
}
.dep-name { color: var(--text); font-weight: 500; }
.dep-ecosystem { margin-left: 4px; font-size: 11px; }
.dep-version { margin-left: 6px; font-size: 11px; }

.error-code {
    font-size: 48px;
    font-weight: bold;
    color: var(--red);
    margin-bottom: 10px;
}
.error-message {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
}
.error-hint {
    margin-bottom: 24px;
}
.error-actions {
    margin-top: 20px;
}

/* ── 1. METRIC GRID (repo detail) ── */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    border: 1px solid var(--border);
    margin-bottom: 10px;
}
.metric-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.metric-cell:last-child { border-right: none; }
.metric-key {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.metric-val {
    color: var(--text);
    font-size: 14px;
}

/* ── 2. SIDE-BY-SIDE CHARTS ── */
.charts-row {
    display: flex;
    gap: 24px;
}
.chart-col {
    flex: 1;
    min-width: 0;
}
.charts-row .bar-label {
    min-width: 70px;
}
.charts-row .bar-value {
    min-width: 44px;
}

/* ── 3. SEARCH / SCROLL HTMX INDICATORS ── */
@keyframes terminal-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}
.htmx-indicator { display: none; }
.htmx-request.htmx-indicator { display: inline; }
.htmx-request .htmx-indicator { display: inline; }
.search-indicator {
    color: var(--green);
    font-size: 13px;
    white-space: nowrap;
    animation: terminal-blink 1s ease-in-out infinite;
}

/* ── 4. SCROLL LOADING ── */
.scroll-loading {
    color: var(--green);
    text-align: center;
    padding: 12px;
    font-size: 13px;
    animation: terminal-blink 1s ease-in-out infinite;
}

/* ── 5. RESULTS END MARKER ── */
.results-end {
    color: var(--muted);
    text-align: center;
    padding: 16px;
    font-size: 12px;
    letter-spacing: 1px;
}

/* ── 6. SUBMIT FORM ── */
.submit-form {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    flex-wrap: wrap;
}
.submit-input {
    min-width: 240px;
    max-width: 360px;
    flex: 1;
}
.submit-btn {
    background: transparent;
    border: 1px solid var(--green);
    color: var(--green);
    padding: 8px 14px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}
.submit-btn:hover {
    background: var(--green);
    color: var(--bg);
}
.submit-btn:focus-visible {
    background: var(--green);
    color: var(--bg);
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

/* ── 8. FOCUS-VISIBLE ── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.copy-btn:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

/* ── 9. MOBILE FLEX-WRAP ── */
@media (max-width: 600px) {
    .nav-search-bar { flex-wrap: wrap; }
    .nav-search-input { min-width: 60%; }
    .charts-row { flex-direction: column; }
    .metric-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

/* ── 10. DIVERGENT IMPLEMENTATIONS ── */

.divergent-entry {
    border-left: 3px solid var(--purple);
    padding-left: 1rem;
    margin-bottom: 1.5rem;
}

.verdict-badge {
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 3px;
    font-size: 0.85rem;
}

.verdict-better {
    color: var(--green);
    border: 1px solid var(--green);
}

.verdict-worse {
    color: var(--red);
    border: 1px solid var(--red);
}

.verdict-different {
    color: var(--blue);
    border: 1px solid var(--blue);
}

.verdict-inconclusive {
    color: var(--muted);
    border: 1px solid var(--border);
}

.divergence-score {
    color: var(--muted);
    font-size: 0.85rem;
}

.cluster-member {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.cluster-member.is-divergent {
    border-color: var(--purple);
}

@media (max-width: 600px) {
    .divergent-entry {
        padding-left: 0.5rem;
    }
}
