.matter-checkbox {
    --matter-helper-theme: var(--matter-theme-rgb, var(--matter-primary-rgb, 33, 150, 243));
    --matter-helper-ontheme: var(--matter-ontheme-rgb, var(--matter-onprimary-rgb, 255, 255, 255));
    z-index: 0;
    position: relative;
    display: inline-block;
    color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.87);
    font-family: var(--matter-font-family, "Roboto", "Segoe UI", BlinkMacSystemFont, system-ui, -apple-system);
    font-size: 16px;
    line-height: 1.5;
}

/* Box */
.matter-checkbox > input {
    appearance: none;
    -moz-appearance: none;
    -webkit-appearance: none;
    z-index: 1;
    position: absolute;
    display: block;
    box-sizing: border-box;
    margin: 3px 1px;
    border: solid 2px; /* Safari */
    border-color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.6);
    border-radius: 2px;
    width: 18px;
    height: 18px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

/* Span */
.matter-checkbox > input + span {
    display: inline-block;
    box-sizing: border-box;
    padding-left: 30px;
    width: inherit;
    cursor: pointer;
}

/* Highlight */
.matter-checkbox > input + span::before {
    content: "";
    position: absolute;
    left: -10px;
    top: -8px;
    display: block;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    background-color: rgb(var(--matter-onsurface-rgb, 0, 0, 0));
    opacity: 0;
    transform: scale(1);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.2s;
}

/* Check Mark */
.matter-checkbox > input + span::after {
    content: "";
    z-index: 1;
    display: block;
    position: absolute;
    top: 3px;
    left: 1px;
    box-sizing: content-box;
    width: 10px;
    height: 5px;
    border: solid 2px transparent;
    border-right-width: 0;
    border-top-width: 0;
    pointer-events: none;
    transform: translate(3px, 4px) rotate(-45deg);
    transition: border-color 0.2s;
}

/* Checked, Indeterminate */
.matter-checkbox > input:checked,
.matter-checkbox > input:indeterminate {
    border-color: rgb(var(--matter-helper-theme));
    background-color: rgb(var(--matter-helper-theme));
}

.matter-checkbox > input:checked + span::before,
.matter-checkbox > input:indeterminate + span::before {
    background-color: rgb(var(--matter-helper-theme));
}

.matter-checkbox > input:checked + span::after,
.matter-checkbox > input:indeterminate + span::after {
    border-color: rgb(var(--matter-helper-ontheme, 255, 255, 255));
}

.matter-checkbox > input:indeterminate + span::after {
    border-left-width: 0;
    transform: translate(4px, 3px);
}

/* Hover, Focus */
.matter-checkbox:hover > input + span::before {
    opacity: 0.04;
}

.matter-checkbox > input:focus + span::before {
    opacity: 0.12;
}

.matter-checkbox:hover > input:focus + span::before {
    opacity: 0.16;
}

/* Active */
.matter-checkbox:active > input,
.matter-checkbox:active:hover > input {
    border-color: rgb(var(--matter-helper-theme));
}

.matter-checkbox:active > input:checked {
    border-color: transparent;
    background-color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.6);
}

.matter-checkbox:active > input + span::before {
    opacity: 1;
    transform: scale(0);
    transition: transform 0s, opacity 0s;
}

/* Disabled */
.matter-checkbox > input:disabled {
    border-color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.38);
    cursor: initial;
}

.matter-checkbox > input:checked:disabled,
.matter-checkbox > input:indeterminate:disabled {
    border-color: transparent;
    background-color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.38);
}

.matter-checkbox > input:disabled + span {
    color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.38);
    cursor: initial;
}

.matter-checkbox > input:disabled + span::before {
    opacity: 0;
    transform: scale(0);
}
