:root {
    --checkbox-selected-bg: #2563eb;
    --checkbox-selected-fg: #fff;
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]) {
    appearance: none;
    -webkit-appearance: none;
    display: inline-grid;
    place-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    padding: 0;
    border: 1.5px solid var(--border-strong, #d4d4d4);
    border-radius: 6px;
    background: var(--surface, #fff);
    color: var(--checkbox-selected-fg);
    box-shadow: none;
    vertical-align: middle;
    cursor: pointer;
    transition: background-color 180ms ease, border-color 180ms ease;
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"])::after,
:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]):checked::after {
    content: "";
    box-sizing: border-box;
    display: block;
    width: 6px;
    height: 11px;
    margin-top: -2px;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    background: none;
    -webkit-mask: none;
    mask: none;
    transform: rotate(45deg);
    opacity: 0;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 420ms cubic-bezier(.4, 0, .2, 1), opacity 140ms ease;
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]):is(:checked, :indeterminate) {
    background: var(--checkbox-selected-bg);
    border-color: var(--checkbox-selected-bg);
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]):is(:checked, :indeterminate)::after {
    opacity: 1;
    clip-path: inset(0);
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]):indeterminate::after {
    width: 10px;
    height: 2px;
    margin: 0;
    border: 0;
    border-radius: 1px;
    background: currentColor;
    transform: none;
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]):focus-visible {
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 3px;
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]):disabled {
    opacity: .45;
    cursor: not-allowed;
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"])[aria-invalid="true"] {
    border-color: var(--destructive, #dc2626);
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"])[aria-invalid="true"]:focus-visible {
    outline-color: var(--destructive, #dc2626);
}

:root input:is([type="checkbox"], [data-checkmark]):not([role="switch"])[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
    :root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]),
    :root input:is([type="checkbox"], [data-checkmark]):not([role="switch"])::after,
    :root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]):is(:checked, :indeterminate)::after { transition: none; }
}

@media (forced-colors: active) {
    :root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]) {
        forced-color-adjust: none;
        border-color: ButtonText;
        background: Canvas;
        color: HighlightText;
    }
    :root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]):is(:checked, :indeterminate) {
        border-color: Highlight;
        background: Highlight;
    }
    :root input:is([type="checkbox"], [data-checkmark]):not([role="switch"]):disabled { border-color: GrayText; }
}
