.atlas-exchanges {
    display: block;
    min-inline-size: 0;
    max-inline-size: 80rem;
    padding: var(--space-md) var(--space-lg) var(--space-xl);
}

.atlas-exchanges h1 {
    margin: 0 0 var(--space-lg);
    font: 700 var(--font-size-2xl) var(--font-headings);
}

.atlas-exchanges__controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
    align-items: end;
    gap: var(--space-md);
    margin-block-end: var(--space-md);
}

.atlas-exchanges__controls label,
.atlas-exchanges__chart-controls label {
    display: grid;
    gap: var(--space-xs);
    min-inline-size: 0;
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
}

.atlas-exchanges__controls :is(input, select),
.atlas-exchanges__chart-controls input {
    box-sizing: border-box;
    inline-size: 100%;
    min-inline-size: 0;
    min-block-size: 2.75rem;
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--color-border-control);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
}

.atlas-exchanges__chart-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: var(--space-xs) var(--space-md);
}

.atlas-exchanges__result {
    display: grid;
    gap: var(--space-md);
}

.atlas-exchanges__chart-controls label {
    inline-size: 8rem;
    max-inline-size: 100%;
}

/* WebKit lets a long native option overflow its grid label. Leave room for the focus outline. */
.atlas-exchanges__controls label:has(select) {
    overflow: clip;
    overflow-clip-margin: 4px;
}

.atlas-exchanges__plot {
    min-inline-size: 0;
}

.atlas-exchanges__plot svg {
    display: block;
    width: 100%;
    min-width: 0;
}

.atlas-exchanges__focus { fill: var(--color-primary-light); }
.atlas-exchanges__guide { stroke: var(--color-border-light); }
.atlas-exchanges__axis { stroke: var(--color-border-control); }

.atlas-exchanges__axis-label {
    fill: var(--color-text-light);
    font-size: var(--font-size-xs);
    font-variant-numeric: tabular-nums;
}

.atlas-exchanges__lane-label {
    fill: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: 700;
}

.atlas-exchanges__outgoing { fill: var(--color-data); }
.atlas-exchanges__incoming { fill: var(--color-role-mentioned); }
.atlas-exchanges__both { fill: var(--color-text); }
.atlas-exchanges__hit { fill: transparent; cursor: pointer; }

.atlas-exchanges__column:hover :is(.atlas-exchanges__outgoing, .atlas-exchanges__incoming) {
    fill: var(--color-primary-dark);
}

.atlas-exchanges__key,
.atlas-exchanges__empty {
    margin: 0;
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
}

.atlas-exchanges__empty:empty { display: none; }

.atlas-exchanges__evidence {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
    gap: var(--space-lg);
}

.atlas-exchanges__pair {
    min-inline-size: 0;
    padding-block: var(--space-xs);
}

.atlas-exchanges__pair h2 {
    margin: 0 0 var(--space-xs);
    overflow-wrap: anywhere;
    font: 700 var(--font-size-md) var(--font-base);
}

.atlas-exchanges__directions {
    display: grid;
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
}

.atlas-exchanges__actions,
.atlas-exchanges__picker-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-lg);
}

.atlas-exchanges :is(.atlas-exchanges__records, .atlas-exchanges__picker-actions button) {
    min-block-size: 2.75rem;
    padding: var(--space-xs) 0;
    border: 0;
    background: transparent;
    color: var(--color-link);
    text-align: start;
    text-decoration: underline;
    text-underline-offset: 0.18em;
    font: inherit;
    cursor: pointer;
}

.atlas-exchanges__picker-actions button:disabled {
    color: var(--color-text-light);
    cursor: default;
    text-decoration: none;
}

.atlas-exchanges :is(input, select, button):focus-visible {
    outline: var(--border-focus);
    outline-offset: 2px;
}

.atlas-exchanges :is([hidden], .atlas-exchanges__result[hidden]) {
    display: none;
}


@media (max-width: 620px) {
    .atlas-exchanges__controls {
        grid-template-columns: minmax(0, 1fr);
        margin-block-end: var(--space-sm);
    }
    .atlas-exchanges__chart-controls { flex-wrap: nowrap; }
    .atlas-exchanges__chart-controls label { flex-shrink: 0; inline-size: 6rem; }
    .atlas-exchanges__key { padding-block-end: var(--space-xs); }
    .atlas-exchanges__evidence {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
        gap: var(--space-xs) var(--space-md);
    }
    .atlas-exchanges__pair h2 { font-size: var(--font-size-sm); }
    .atlas-exchanges__directions { font-size: var(--font-size-xs); }
}
