.code-block-container {
    /* 85% of the streamfield on desktop, centred; full width once the
       streamfield itself goes narrow. */
    width: 85%;
    margin: 24px auto;
}

.code-block {
    /* Surface and text match the vendored GitHub Dark Dimmed highlight.js theme,
       which paints the `.hljs` code element itself. Swapping that theme file means
       revisiting these two. */
    --code-block-surface: #22272e;
    --code-block-text: #adbac7;
    --code-block-header: #1c2128;
    --code-block-border: rgba(255, 255, 255, 0.1);
    --code-block-muted: #9198a1;
    box-sizing: border-box;
    width: 100%;
    margin: 0px;
    background: var(--code-block-surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(17, 17, 17, 0.08), 0 0 0 1px rgba(17, 17, 17, 0.04);
}

.code-block *,
.code-block *::before,
.code-block *::after {
    box-sizing: border-box;
}

.code-block .code-block__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 10px 8px 16px;
    background: var(--code-block-header);
    border-bottom: 1px solid var(--code-block-border);
}

.code-block .code-block__label {
    min-width: 0px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--code-block-muted);
    font-family: var(--font-family, "Univers", Arial, sans-serif);
    font-size: 13px;
    line-height: 18px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Copy button */
.code-block .code-block__copy {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--code-block-border);
    border-radius: 6px;
    background: transparent;
    color: var(--code-block-muted);
    font-family: var(--font-family, "Univers", Arial, sans-serif);
    font-size: 13px;
    line-height: 18px;
    font-weight: 500;
    padding: 5px 10px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.code-block .code-block__copy:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.code-block .code-block__copy:focus-visible {
    outline: 2px solid var(--brand-colour, #204cfe);
    outline-offset: 2px;
}

.code-block .code-block__copy svg {
    width: 15px;
    height: 15px;
    flex: none;
}

.code-block .code-block__copied-icon {
    display: none;
}

.code-block.is-copied .code-block__copy {
    color: #57ab5a;
    border-color: rgba(87, 171, 90, 0.5);
}

.code-block.is-copied .code-block__copy-icon {
    display: none;
}

.code-block.is-copied .code-block__copied-icon {
    display: block;
}

/* Code surface */
.code-block .code-block__pre {
    margin: 0px;
    padding: 16px;
    overflow-x: auto;
    background: transparent;
    border: 0px;
    border-radius: 0px;
    tab-size: 4;
    /* Set here rather than on the code element so the theme's `.hljs` colour, which
       is less specific than `.code-block .code-block__code`, still wins once
       highlighting has run. This is only what shows if the script never loads. */
    color: var(--code-block-text);
}

/*
 * Layout only. The vendored theme owns every colour on this element, so nothing
 * here may set `color`. The overrides below undo the theme's own `pre code.hljs`
 * padding and scrolling, which would otherwise double up with the `pre`.
 */
.code-block .code-block__code {
    display: block;
    background: transparent;
    padding: 0px;
    overflow-x: visible;
    font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas,
        "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 22px;
    white-space: pre;
    /* Article stylesheets add a shadow to inline code; the theme does not want it. */
    text-shadow: none;
}

@media only screen and (max-width: 999px) {
    .code-block-container {
        width: 100%;
    }

    .code-block .code-block__code {
        font-size: 13px;
        line-height: 20px;
    }
}
