:root {
    --background: #121212;
    --primary: #0099ff;
    --secondary: #f5f5f5;
    --accent: #ff6b6b;
    --light-gray: #2a2a2a;
    --border: #333333;
    --text-muted: #999999;
}

body {
    background-color: var(--background);
    color: var(--secondary);
    color-scheme: dark;
    line-height: 1.65;
    padding: 20px;
    min-height: 100vh;
}

.site-nav {
    max-width: 880px;
    margin: 0 auto 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
}

.site-nav a {
    color: var(--primary);
    text-decoration: none;
    font-family: 'Courier New', monospace;
}

.site-nav a:hover {
    text-decoration: underline;
}

.site-nav .sep {
    color: var(--border);
    user-select: none;
}

.article-wrap {
    max-width: 880px;
    margin: 0 auto;
}

.article-body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 1.05rem;
}

.article-body h1 {
    font-size: 1.85rem;
    color: var(--primary);
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.article-body h2 {
    font-size: 1.35rem;
    color: var(--accent);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.article-body h3 {
    font-size: 1.15rem;
    color: var(--secondary);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.article-body h4, .article-body h5, .article-body h6 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--secondary);
}

.article-body p {
    margin-bottom: 1rem;
}

.article-body a {
    color: var(--primary);
}

.article-body a:hover {
    color: #33adff;
}

.article-body ul, .article-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.article-body li {
    margin: 0.35rem 0;
}

.article-body li::marker {
    color: var(--accent);
}

.article-body blockquote {
    border-left: 4px solid var(--primary);
    margin: 1.25rem 0;
    padding: 0.5rem 0 0.5rem 1.25rem;
    color: var(--text-muted);
    background: var(--light-gray);
    border-radius: 0 6px 6px 0;
}

.article-body blockquote p:last-child {
    margin-bottom: 0;
}

.article-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.article-body strong {
    color: var(--secondary);
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.95rem;
}

.article-body th, .article-body td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.article-body th {
    background: var(--light-gray);
    color: var(--primary);
}

#status {
    font-family: 'Courier New', monospace;
    color: var(--text-muted);
}

#status.error {
    color: var(--accent);
}

.article-chart {
    margin: 1.25rem auto;
    padding: 0.55rem 0.75rem;
    background: var(--light-gray);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
}

.article-chart.chart-flowchart {
    max-width: 520px;
}

.chart-heading {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
    text-align: center;
}

.stackbar {
    display: flex;
    height: 2rem;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
    font-size: 0.72rem;
    font-weight: 600;
}

.stack-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
}

.stack-major {
    background: var(--primary);
    color: #121212;
}

.stack-minor {
    background: var(--border);
    color: var(--text-muted);
}

.stack-knots {
    background: #3a5a6a;
    color: var(--secondary);
}

.fund-network {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.net-tier {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.5rem;
    width: 100%;
}

.net-tier-bridge {
    padding: 0.1rem 0;
}

.net-tier-target {
    margin-top: 0.15rem;
}

.net-node {
    display: inline-block;
    padding: 0.32rem 0.55rem;
    background: var(--background);
    border: 1px solid var(--primary);
    border-radius: 4px;
    color: var(--secondary);
    font-size: 0.75rem;
    line-height: 1.25;
    text-align: center;
}

.net-node-target {
    border-color: var(--accent);
    font-weight: 600;
}

.net-conn {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.net-bridge {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

.net-tag {
    display: block;
    font-size: 0.62rem;
    color: var(--accent);
    font-weight: 600;
    margin-top: 0.1rem;
}

.article-chart.chart-network {
    max-width: 480px;
}

.exits-compare {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
}

.exits-col {
    width: 100%;
    text-align: center;
}

.exits-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.exits-bridge {
    margin: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.flow-node-muted {
    border-color: var(--border);
    color: var(--text-muted);
    border-style: dashed;
}

.article-chart.chart-exits {
    max-width: 520px;
}

.article-chart.chart-exits .flowchart-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.25rem;
}

.stackbar-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.25rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chart-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.25rem;
    margin: 0.65rem 0 0;
    font-size: 0.78rem;
}

.chart-stats div {
    display: flex;
    gap: 0.35rem;
}

.chart-stats dt {
    color: var(--text-muted);
    font-weight: normal;
}

.chart-stats dd {
    margin: 0;
    color: var(--secondary);
    font-weight: 600;
}

.intensity-row {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.45rem;
}

.intensity-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--secondary);
}

.intensity-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.intensity-track {
    flex: 1;
    background: var(--background);
    border-radius: 3px;
    border: 1px solid var(--border);
    height: 1.5rem;
    overflow: hidden;
}

.intensity-fill {
    display: block;
    height: 100%;
    min-width: 2px;
    background: var(--primary);
}

.intensity-fill.intensity-alt {
    background: #3a6a8a;
}

.intensity-fill.intensity-review {
    background: var(--accent);
}

.stack-active {
    background: #2a6a4a;
    color: var(--secondary);
}

.article-chart.chart-gini {
    max-width: 480px;
}

.compare-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.compare-col {
    padding: 0.5rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--background);
}

.compare-open {
    border-color: var(--primary);
}

.compare-gated {
    border-color: var(--accent);
}

.compare-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 0.35rem;
}

.compare-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.compare-list li {
    margin: 0.2rem 0;
}

.article-chart.chart-compare {
    max-width: 520px;
}

.intensity-value {
    font-size: 0.75rem;
    color: var(--secondary);
    white-space: nowrap;
    min-width: 3.25rem;
    text-align: right;
}

.flowchart-ladder,
.flowchart-layers .flowchart-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.25rem;
}

.flowchart-layers {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.flow-node {
    display: inline-block;
    padding: 0.32rem 0.55rem;
    background: var(--background);
    border: 1px solid var(--primary);
    border-radius: 4px;
    color: var(--secondary);
    font-size: 0.75rem;
    line-height: 1.25;
}

.flow-arrow {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1;
    flex-shrink: 0;
}

.flow-link {
    margin: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.article-chart .chart-svg {
    display: flex;
    justify-content: center;
}

.article-chart .chart-svg svg.mermaid-svg {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
}

.article-chart.chart-xychart .chart-svg svg.mermaid-svg {
    max-width: 420px;
    max-height: 220px;
}

.article-chart.chart-xychart .chart-svg svg.mermaid-svg text,
.article-chart.chart-xychart .chart-svg svg.mermaid-svg .label text,
.article-chart.chart-xychart .chart-svg svg.mermaid-svg .nodeLabel {
    fill: var(--secondary);
}

.article-chart figcaption {
    margin-top: 0.75rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

.article-chart table.chart-matrix {
    margin: 0;
    font-size: 0.88rem;
}

.article-chart table.chart-matrix th {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.article-chart table.chart-matrix td:first-child {
    font-weight: 600;
    white-space: nowrap;
}

.article-chart table.chart-matrix tr.close-yes td:last-child {
    color: #5dca8a;
}

.article-chart table.chart-matrix tr.close-partial td:last-child {
    color: #e8b84a;
}

.article-chart table.chart-matrix tr.close-no td:last-child {
    color: var(--accent);
}

@media (max-width: 600px) {
    .article-chart table.chart-matrix {
        font-size: 0.78rem;
    }

    .article-chart table.chart-matrix th,
    .article-chart table.chart-matrix td {
        padding: 0.4rem 0.5rem;
    }

    .intensity-row {
        grid-template-columns: 4.75rem 1fr;
    }

    .compare-cols {
        grid-template-columns: 1fr;
    }

    .net-node {
        font-size: 0.7rem;
        padding: 0.28rem 0.45rem;
    }
}
