html[data-theme="dark"] {
    --header-bg: #1b1b1b;
    --header-color: #f7f7f7;
    --header-link-color: #f7f7f7;

    --breadcrumbs-bg: #1b1b1b;
    --breadcrumbs-fg: #b0b3b8;
    --breadcrumbs-link-fg: #b0b3b8;

    --er-divider: #353535;
    --er-icon: #b0b3b8;
    --er-toggle-fg: #fff;
    --er-cta: #7cb7ff;
    --er-hover: rgb(255 255 255 / 0.08);
}

#container > #header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 70px;
    box-sizing: border-box;
    padding: 16px 40px;
    background: var(--header-bg);
    color: var(--header-color);
    font-size: 1rem;
    line-height: 1.6;
    /* base.css sets overflow: hidden, which clips the open dropdown. */
    overflow: visible;
}

#container > #header #site-name {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
}

#container > #header .er-brand {
    display: inline-flex;
    align-items: center;
    border-bottom: 0;
    text-decoration: none;
}

#container > #header .er-brand__logo {
    display: block;
    width: 255px;
    height: 32px;
    max-width: 100%;
}

html[data-theme="dark"] .er-brand__logo {
    filter: brightness(0) invert(1);
}

#container > #header #user-tools {
    float: none;
    display: flex;
    align-items: center;
    gap: 24px;
    margin: 0;
    padding: 0;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: normal;
    line-height: 1.6;
    text-align: start;
    text-transform: none;
}

#container > #header #user-tools a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    color: var(--header-link-color);
    text-decoration: none;
    border-bottom: 0;
}

#container > #header #user-tools a:hover {
    color: var(--er-cta);
}

#container > #header #branding {
    flex: 1;
    align-items: center;
    justify-content: space-between;
}

#container > #header .er-menu {
    position: relative;
}

#container > #header .er-menu > summary {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 38px;
    color: var(--header-color);
    list-style: none;
    cursor: pointer;
}

#container > #header .er-menu > summary::-webkit-details-marker {
    display: none;
}

#container > #header .er-menu > summary:hover,
#container > #header .er-menu > summary:focus-visible {
    color: var(--er-cta);
}

#container > #header .er-menu__caret {
    flex: none;
    transition: transform 150ms ease;
}

#container > #header .er-menu[open] > summary .er-menu__caret {
    transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
    #container > #header .er-menu__caret {
        transition: none;
    }
}

#container > #header .er-menu__panel {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    padding: 6px;
    background: var(--header-bg);
    border: 1px solid var(--er-divider);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.12);
    overflow: visible;
}

#container > #header .er-menu__panel a,
#container > #header .er-menu__panel button {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    min-height: 44px;
    margin: 0;
    padding: 10px 12px;
    background: none;
    border: 0;
    border-radius: 2px;
    font: inherit;
    letter-spacing: normal;
    text-transform: none;
    text-align: start;
    text-decoration: none;
    color: var(--header-link-color);
    cursor: pointer;
}

#container > #header .er-menu__panel a:hover,
#container > #header .er-menu__panel a:focus-visible,
#container > #header .er-menu__panel button:hover,
#container > #header .er-menu__panel button:focus-visible {
    background: var(--er-hover, rgb(0 0 0 / 0.05));
    color: var(--er-cta);
}

/* base.css sets #logout-form to display: inline. */
#container > #header #logout-form {
    display: contents;
}

#container > #header .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    margin: 0;
    padding: 0;
    line-height: 1;
    vertical-align: baseline;
    color: var(--er-toggle-fg);
}

#container > #header .theme-toggle svg {
    width: 16px;
    height: 16px;
}

/* dark_mode.css pins fill on these symbols, so the button's color never reaches the glyph. */
#container > #header .theme-toggle svg.theme-icon-when-auto,
#container > #header .theme-toggle svg.theme-icon-when-dark,
#container > #header .theme-toggle svg.theme-icon-when-light {
    fill: var(--er-toggle-fg);
    color: var(--header-bg);
}

#container > #header .theme-toggle:hover svg.theme-icon-when-auto,
#container > #header .theme-toggle:hover svg.theme-icon-when-dark,
#container > #header .theme-toggle:hover svg.theme-icon-when-light,
#container > #header .theme-toggle:focus-visible svg.theme-icon-when-auto,
#container > #header .theme-toggle:focus-visible svg.theme-icon-when-dark,
#container > #header .theme-toggle:focus-visible svg.theme-icon-when-light {
    fill: var(--er-cta);
}

#container > .er-breadcrumbs {
    background: var(--breadcrumbs-bg);
    padding: 0 40px 16px;
    border-bottom: 1px solid var(--er-divider);
}

#container > .er-breadcrumbs:not(:has(> *)) {
    display: none;
}

#container > .er-breadcrumbs div.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 8px;
    row-gap: 4px;
    padding: 0;
    background: none;
    color: var(--breadcrumbs-fg);
    font-size: 1rem;
    line-height: 1.6;
}

#container > .er-breadcrumbs div.breadcrumbs > * {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow-wrap: anywhere;
}

#container > .er-breadcrumbs div.breadcrumbs a {
    color: var(--breadcrumbs-link-fg);
    text-decoration: none;
}

#container > .er-breadcrumbs div.breadcrumbs a:hover,
#container > .er-breadcrumbs div.breadcrumbs a:focus-visible {
    color: var(--er-cta);
    text-decoration: none;
}

#container > .er-breadcrumbs [aria-current="page"] {
    color: var(--er-cta);
}

#container > .er-breadcrumbs div.breadcrumbs > *:not(:first-child)::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--er-icon);
    border-bottom: 1.5px solid var(--er-icon);
    transform: rotate(-45deg) translateY(-1px);
    margin-inline-end: 4px;
}

.er-admin-switch {
    margin: 0 0 24px;
}

#container > #header a:focus-visible,
#container > #header summary:focus-visible,
#container > #header button:focus-visible,
#container > .er-breadcrumbs a:focus-visible {
    outline: 2px solid var(--er-cta);
    outline-offset: 2px;
    border-radius: 2px;
}

@media (max-width: 1024px) {
    #container > #header {
        /* responsive.css switches this to column. */
        flex-direction: row;
        justify-content: space-between;
        padding: 16px 24px;
    }

    #container > .er-breadcrumbs {
        padding: 0 24px 12px;
    }
}

@media (max-width: 767px) {
    #container > #header {
        height: auto;
        /* Branding, then user tools, each on its own row. */
        flex-direction: column;
        align-items: stretch;
        row-gap: 12px;
        padding: 12px 16px;
    }

    /* Without this #branding keeps growing and #user-tools never gets its own row. */
    #container > #header #branding {
        flex: none;
    }

    #container > #header #user-tools a,
    #container > #header .er-menu > summary,
    #container > #header .theme-toggle {
        min-height: 44px;
    }

    #container > #header .theme-toggle {
        min-width: 44px;
    }

    #container > #header .er-menu__panel {
        inset-inline-start: 0;
        inset-inline-end: auto;
        max-width: calc(100vw - 32px);
    }

    #container > #header #user-tools {
        flex-wrap: wrap;
        gap: 16px;
    }

    #container > #header .er-brand__logo {
        width: 100%;
        max-width: 220px;
        height: auto;
    }

    #container > .er-breadcrumbs {
        padding: 0 16px 12px;
    }
}
