:root {
    --color-primary: #087e8b;
    --color-on-primary: white;
    --color-background: #222;
    --color-danger: #fa2b58;
    --icon-button-size: 2.5rem;
}

body {
    margin: 0;
    padding: 0;
    background: linear-gradient(to left, #065760, black, black, #065760);
    color: white;
    font-family: Arial, Helvetica, sans-serif;
    overflow: hidden;
}

main {
    background-color: var(--color-background);
    max-width: 700px;
    padding: 8px max(5%, 8px);
    margin: 0 auto;
    height: 100vh;
    overflow: scroll;
}

h1 {
    text-align: center;
}

form > * {
    margin-bottom: 16px;
}

fieldset {
    border-radius: 8px;
}

label {
    display: block;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

label span {
    flex-grow: 1;
}

input,
select {
    width: clamp(200px, 100%, 400px);
    background-color: var(--color-background);
    color: white;
    border: 1px solid white;
    border-radius: 8px;
    padding: 8px;
    box-sizing: border-box;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
}

select:has(+ .icon-button) {
    width: calc(clamp(200px, 100%, 400px) - var(--icon-button-size) - 8px);
}

button {
    border: none;
    inset: none;
    border-radius: 8px;
    background-color: var(--color-primary);
    color: var(--color-on-primary);
    padding: 8px 16px;
}

button[type="reset"] {
    background-color: var(--color-danger);
}

:is(div:has(:is(input, select)), input, select, label)
    + :is(div:has(:is(input, select)), input, select, label) {
    margin-top: 8px;
}

.hidden {
    display: none !important;
}

label.switch {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    -webkit-user-select: none;
    user-select: none;
}

label.switch input {
    display: none;
}

label.switch .slider {
    display: inline-block;
    position: relative;
    height: 1em;
    width: 2em;
    background-color: #444;
    border-radius: 1em;
    border: 4px solid #444;
}

label.switch .slider::before {
    content: "";
    position: absolute;
    height: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    top: 50%;
    background-color: white;
    transition: all 0.1s linear;
}

label.switch:active .slider::before {
    transform: scale(1.3);
    transform-origin: 50% 50%;
}

label.switch input:not(:checked) + .slider::before {
    left: 0%;
    translate: 0 -50%;
}

label.switch input:checked + .slider::before {
    left: 100%;
    translate: -100% -50%;
}

.buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 8px;
}

.loading-screen {
    display: grid;
    justify-content: center;
}

.error {
    color: var(--color-danger);
}

.error-bg {
    background-color: var(--color-danger) !important;
}

button.reload {
    display: block;
    margin: 0 auto;
}

.spinner-container {
    width: min(max-content, 100%);
}

.spinner {
    position: relative;
    margin: 10px auto;
    background: conic-gradient(transparent 150deg, var(--color-primary));
    --outer-diameter: 50px;
    width: var(--outer-diameter);
    height: var(--outer-diameter);
    border-radius: 50%;

    animation-name: spin;
    animation-duration: 1s;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
}

.spinner::after {
    position: absolute;
    content: "";
    display: block;
    --spinner-border: 5px;
    top: var(--spinner-border);
    left: var(--spinner-border);

    --inner-diameter: calc(var(--outer-diameter) - 2 * var(--spinner-border));
    width: var(--inner-diameter);
    height: var(--inner-diameter);

    background-color: var(--color-background);
    border-radius: 50%;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.icon-button {
    padding: 8px;
    font-size: 0;
    width: var(--icon-button-size);
    height: var(--icon-button-size);
}

.spinning {
    animation-name: spin;
    animation-duration: 0.5s;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
}
