.background-actions {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 8px;
}

.background-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 44px;
    box-sizing: border-box;
    padding: 7px 12px;
    border: 1px solid #3152bf;
    border-radius: 6px;
    background: #fff;
    color: #2444a8;
    font: 700 14px/1.35 'Open Sans', sans-serif;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.background-action:hover {
    background: #edf2ff;
    color: #1d3790;
    text-decoration: none;
}

.background-action--download,
.background-action--download:visited {
    background: #294bc5;
    color: #fff;
}

.background-action--download:hover {
    background: #203da5;
    color: #fff;
}

.background-action[hidden],
.background-color-viewer:not([open]),
.background-color-viewer [hidden] {
    display: none;
}

html:has(.background-color-viewer[open]) {
    overflow: hidden;
}

.background-color-viewer {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
}

.background-color-screen {
    position: relative;
    display: grid;
    justify-items: center;
    align-items: end;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
        max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: var(--display-color);
    forced-color-adjust: none;
}

.background-color-toolbar {
    box-sizing: border-box;
    width: min(100%, 440px);
    max-height: 100%;
    overflow: auto;
    padding: 9px;
    border: 1px solid #d8deeb;
    border-radius: 10px;
    background: #fff;
    color: #172032;
    box-shadow: 0 3px 16px #0003;
    forced-color-adjust: auto;
}

.background-color-swatches {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
}

.background-color-swatch {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 4px;
    min-height: 56px;
    min-width: 0;
    padding: 4px 2px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: #fff;
    color: #172032;
    font: 700 12px/1.35 'Open Sans', sans-serif;
    cursor: pointer;
}

.background-color-swatch span {
    box-sizing: border-box;
    width: min(100%, 40px);
    height: 25px;
    border: 1px solid #80808080;
    border-radius: 4px;
    background: var(--swatch-color);
    forced-color-adjust: none;
}

.background-color-swatch:hover,
.background-color-swatch[aria-pressed='true'] {
    background: #edf2ff;
}

.background-color-swatch[aria-pressed='true'] {
    border-color: #3152bf;
}

.background-color-controls {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    margin-top: 8px;
    padding-top: 4px;
    border-top: 1px solid #d8deeb;
}

.background-color-controls .background-action {
    border-color: transparent;
}

.background-color-reveal {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: none;
}

/* The restore target spans the entire screen so the selected color stays uniform. */
.background-color-reveal:focus {
    outline: none;
}

@media (max-width: 440px) {
    .background-color-swatches {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
