#desktop-background {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

#minimized-tray.background-tray {
    display: flex;
    height: 40px;
    flex-wrap: nowrap;
    overflow: hidden;
}

#minimized-tray.background-tray ~ .wrapper {
    padding-top: 56px !important;
}

#minimized-tray .tray-tabs-container {
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
}

#minimized-tray .tray-tabs-container:empty {
    display: none;
}

#minimized-tray .tray-tab {
    flex: 0 0 auto;
    white-space: nowrap;
}

#background-settings-toggle,
#background-settings button,
#background-settings select {
    font: inherit;
    color: #203823;
    border: 1px solid #67845b;
    border-radius: 2px;
    background: #f3f5e9;
    padding: 4px 9px;
}

#background-settings-toggle {
    margin-left: auto;
    flex: 0 0 auto;
    white-space: nowrap;
}

#background-settings-toggle:hover,
#background-settings button:hover {
    background: #fff;
}

#background-settings {
    position: fixed;
    inset: calc(var(--desktop-tray-height, 34px) + 8px) 8px auto auto;
    box-sizing: border-box;
    margin: 0;
    width: min(410px, calc(100vw - 16px));
    max-height: calc(100dvh - var(--desktop-tray-height, 34px) - 16px);
    overflow: auto;
    border: 2px solid #67845b;
    border-radius: 3px;
    background: #f3f5e9;
    color: #203823;
    box-shadow: 3px 4px 0 #253e32aa;
    padding: 12px;
}

#background-settings header,
#background-settings footer,
.background-settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

#background-settings header {
    font-size: 1.15em;
    font-weight: bold;
}

.background-settings-row, #background-settings footer {
    margin-top: 10px;
}

#background-settings input[type="range"] {
    width: 50%;
    accent-color: #436a45;
}

#background-settings input[type="color"] {
    width: 44px;
}

#background-preview {
    height: clamp(104px, 25vh, 176px);
    margin-top: 10px;
    border: 1px solid #67845b;
    background: #24352b url('img/bg/dithered_fhd.webp') center / cover;
    overflow: hidden;
}

#background-preview #desktop-background {
    position: relative;
    display: block;
}

#background-preview #desktop-background[hidden] {
    display: none;
}

#background-status {
    margin: 8px 0 0;
}

#minimized-tray #tray-preset-controller[hidden] {
    display: none;
}

#minimized-tray .tray-preset-controller {
    box-sizing: border-box;
    min-width: 0;
    max-width: min(48vw, 220px);
}

#tray-preset-controller:not([hidden]) ~ #background-settings-toggle {
    margin-left: 0;
}

#minimized-tray .tray-preset-name,
#minimized-tray .preset-mode-badge {
    background: transparent;
    border: 0;
    min-width: 0;
    font-family: inherit;
}

#background-effect, #background-preset, #background-template-select {
    min-width: 0;
    max-width: 75%;
}

.background-browse {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.background-browse button:nth-child(2) {
    flex: 1;
}

#background-description {
    margin: 8px 0;
    line-height: 1.25;
    color: #3b5140;
}

#background-settings details {
    margin-top: 10px;
    padding: 6px 0 0;
    border-top: 1px solid #bccbad;
}

#background-settings summary {
    cursor: pointer;
}

#background-settings input[type="number"],
.background-color input[type="text"],
#background-template-form input[type="text"] {
    box-sizing: border-box;
    width: 72px;
    min-width: 0;
    font: inherit;
    color: inherit;
    background: #fff;
    border: 1px solid #9aac93;
    border-radius: 2px;
    padding: 3px 5px;
}

#background-settings input[type="range"]:not([data-setting]) {
    width: 28%;
    min-width: 55px;
}

#background-settings input[type="file"] {
    max-width: 73%;
    font: inherit;
}

#background-settings fieldset {
    border: 1px solid #bccbad;
    margin: 8px 0;
    padding: 6px 8px;
    min-width: 0;
}

#background-settings fieldset > button {
    margin-top: 5px;
}

.background-color, .background-palette-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.background-color input[type="text"] {
    width: min(125px, 35vw);
}

.background-palette-row {
    margin: 3px 0;
}

#background-settings-toggle:focus-visible,
#background-settings :focus-visible {
    outline: 2px solid #315a3a;
    outline-offset: 2px;
}

#background-template-form input[type="text"] {
    width: min(55%, 220px);
}

#background-template-form button,
#background-download-webp,
.background-template-actions {
    margin-top: 6px;
}

.background-template-actions {
    display: flex;
    gap: 6px;
}

#background-storage-status {
    margin: 8px 0 0;
}

.background-image-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

#background-settings .background-image-actions input[type="file"] {
    width: 175px;
    max-width: 100%;
}
