.code-block {
    border: 1px solid rgba(34, 36, 38, .15);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5em;
}

.code-block-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    padding: 4px 8px;
    background: #f7f7f7;
    border-bottom: 1px solid rgba(34, 36, 38, .15);
}

.code-block-toolbar .code-copy-btn.copied {
    color: #21ba45;
}

.code-block-body {
    max-height: 340px;
    overflow: auto;
    margin: 0;
    padding: 10px 14px;
    background: #fbfbfb;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.85em;
}

/* Nodes section: one row per node, with what is not label, role or
   description behind the row's toggle. */
.node-list-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .5em 1em;
    margin-bottom: .75em;
}

.node-expand-all {
    border: 0;
    padding: 0;
    background: none;
    font: inherit;
    color: #2f6fa7;
    cursor: pointer;
}

.node-expand-all:hover {
    text-decoration: underline;
}

.node-list {
    border: 1px solid rgba(34, 36, 38, .15);
    border-radius: 4px;
}

.node-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.node-list-head,
.node-summary {
    display: grid;
    grid-template-columns: minmax(14em, 1.5fr) minmax(0, 2.5fr) 7.5em;
    gap: 1em;
    align-items: start;
    padding: .7em .8em;
}

.node-list-head {
    background: #f9fafb;
    font-weight: bold;
    border-bottom: 1px solid rgba(34, 36, 38, .15);
}

.node-row + .node-row {
    border-top: 1px solid rgba(34, 36, 38, .1);
}

.node-row[hidden] {
    display: none;
}

summary.node-summary {
    cursor: pointer;
    list-style: none;
}

summary.node-summary::-webkit-details-marker {
    display: none;
}

summary.node-summary:hover,
.node-row details[open] {
    background: #f7f9fb;
}

.node-name {
    display: grid;
    gap: .15em;
    min-width: 0;
}

.node-label {
    font-weight: bold;
    overflow-wrap: anywhere;
}

.node-role {
    color: rgba(0, 0, 0, .6);
    font-size: .8em;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.node-description {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* The role's colour as a bar on the row's edge, in graph_theme.ROLE_COLORS,
   so the list reads as the figure's legend; unmeasured wins, as it does in
   the figure. Covariates get none. NodeDetailsTests holds the two together. */
.node-row {
    border-left: 4px solid transparent;
}

.node-row.node-exposure { border-left-color: #009E73; }
.node-row.node-outcome { border-left-color: #D55E00; }
.node-row.node-unmeasured { border-left: 4px dashed #8c9096; }

.node-more {
    justify-self: end;
    color: #2f6fa7;
    font-size: .9em;
    white-space: nowrap;
}

.node-more .dropdown.icon {
    margin: 0;
    transition: transform .15s ease;
}

.node-row details[open] .node-more .dropdown.icon {
    transform: rotate(180deg);
}

.node-details {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: .4em 1.5em;
    margin: 0 .8em .8em;
    padding: .75em 1em;
    background: #fff;
    border: 1px solid rgba(34, 36, 38, .1);
    border-radius: 4px;
}

.node-details dt {
    color: rgba(0, 0, 0, .55);
}

.node-details dd {
    margin: 0;
    min-width: 0;
}

.node-identifiers {
    display: flex;
    flex-wrap: wrap;
    gap: .2em 1.2em;
}

.node-identifiers a,
.node-unit {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: .9em;
    overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
    .node-more .dropdown.icon {
        transition: none;
    }
}

@media (max-width: 600px) {
    .node-list-head {
        display: none;
    }

    .node-summary {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: .35em .75em;
    }

    .node-description {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .node-details {
        grid-template-columns: minmax(0, 1fr);
        gap: .1em;
    }

    .node-details dd + dt {
        margin-top: .5em;
    }
}

/* Edges section: a List tab, one line per edge with its justification and
   references under it, and a Matrix tab of row node -> column node. Each
   edge's type is the graph builder's Semantic UI icon (EDGE_TYPE_ICONS);
   the matrix marks an edge with that icon on a cell coloured by its sign. */
.edge-list {
    list-style: none;
    margin: 0 0 1em;
    padding: 0;
    border: 1px solid rgba(34, 36, 38, .15);
    border-radius: 4px;
}

.edge-row {
    padding: .7em .8em;
}

.edge-row + .edge-row {
    border-top: 1px solid rgba(34, 36, 38, .1);
}

.edge-claim {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .3em .6em;
}

.edge-node {
    font-weight: bold;
    overflow-wrap: anywhere;
}

.edge-claim i.icon.edge-icon {
    margin: 0;
    color: rgba(0, 0, 0, .6);
}

.edge-list.excluded i.icon.edge-icon {
    color: #b42318;
}

/* The Nodes section's chip, outlined: these qualify an edge rather than
   name a role, so they stay clear of the role colours. */
.edge-chip {
    display: inline-block;
    padding: .1em .5em;
    border: 1px solid rgba(34, 36, 38, .2);
    border-radius: 3px;
    font-size: .8em;
    line-height: 1.4;
    white-space: nowrap;
    color: rgba(0, 0, 0, .7);
}

.edge-chip.sign-positive { border-color: #1a7f37; color: #1a7f37; }
.edge-chip.sign-negative { border-color: #b42318; color: #b42318; }
.edge-chip.sign-ambiguous { border-color: #6b7280; color: #6b7280; }

.edge-justification {
    margin: .35em 0 0;
    color: rgba(0, 0, 0, .75);
    overflow-wrap: anywhere;
}

.edge-references {
    display: flex;
    flex-wrap: wrap;
    gap: .2em 1.2em;
    margin-top: .3em;
}

.edge-references a {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: .85em;
    overflow-wrap: anywhere;
}

/* Scrolls sideways for any graph wider than the column; the row labels
   stay in view while it does. */
.edge-matrix-wrap {
    overflow-x: auto;
    border: 1px solid rgba(34, 36, 38, .15);
    border-radius: 4px;
}

.edge-matrix {
    border-collapse: collapse;
    font-size: .9em;
}

.edge-matrix-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .3em 1.2em;
    list-style: none;
    margin: 0 0 .6em;
    padding: 0;
    color: rgba(0, 0, 0, .7);
}

.edge-matrix-legend li {
    display: flex;
    align-items: center;
    gap: .4em;
}

.edge-matrix-swatch {
    width: 1em;
    height: 1em;
    border-radius: 2px;
}

.edge-matrix-swatch,
.edge-matrix td.edge {
    background-color: #2185d0;
}

.sign-positive.edge-matrix-swatch,
.edge-matrix td.edge.sign-positive { background-color: #1a7f37; }
.sign-negative.edge-matrix-swatch,
.edge-matrix td.edge.sign-negative { background-color: #b42318; }
.sign-ambiguous.edge-matrix-swatch,
.edge-matrix td.edge.sign-ambiguous { background-color: #6b7280; }

/* The type's mark, the List tab's icon: white on a cell, dark in the
   legend. */
i.icon.edge-matrix-mark {
    margin: 0;
    color: rgba(0, 0, 0, .7);
}

.edge-matrix td.edge i.icon.edge-matrix-mark {
    color: #fff;
}

.edge-matrix th,
.edge-matrix td {
    border: 1px solid rgba(34, 36, 38, .1);
    padding: .3em .45em;
}

.edge-matrix thead th {
    vertical-align: bottom;
    background: #f9fafb;
}

.edge-matrix thead th span {
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    max-height: 12em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
}

.edge-matrix tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    max-width: 14em;
    background: #f9fafb;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edge-matrix-corner {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #f9fafb;
}

.edge-matrix td {
    min-width: 2.6em;
    text-align: center;
    white-space: nowrap;
}

.edge-matrix td.none::after {
    content: "\00b7";
    color: rgba(0, 0, 0, .25);
}

.edge-matrix td.self {
    background: repeating-linear-gradient(135deg, #f3f4f6 0 3px, #fff 3px 6px);
}

.edge-matrix tbody tr:hover th,
.edge-matrix tbody tr:hover td:not(.edge) {
    background-color: #f1f5f9;
}

@media (max-width: 600px) {
    .edge-matrix tbody th {
        max-width: 8em;
    }
}

/* The download icon trails the original-submission filename. */
#code .raw-input-icon {
    margin: 0 0 0 0.25em;
}
